aboutsummaryrefslogtreecommitdiff
path: root/libnos_transport
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@google.com>2021-07-27 10:56:45 -0500
committerBill Richardson <wfrichar@google.com>2021-07-27 22:59:52 +0000
commitc3fe8f4a6d0aca78d77ed944837cf5995674b29e (patch)
tree17416827e985de51f80cbb05ac9170757c4095da /libnos_transport
parent2d4d7c33154ce5723d6414b666141df537242117 (diff)
downloadgeneric-c3fe8f4a6d0aca78d77ed944837cf5995674b29e.tar.gz
Fix uninitialized memory in nos_call_application()
nos_call_application() poll_until_done() get_status() <= clear output struct before returning Bug: 193528049 Test: manual, release tests Signed-off-by: Bill Richardson <wfrichar@google.com> Change-Id: I947e3c64544bbc7fde24567bb5b7048f1a4440d9 Reviewed-on: https://nugget-os-review.googlesource.com/c/host/generic/+/46166 Presubmit-Verified: TreeHugger Robot <android-build-prod@system.gserviceaccount.com> Reviewed-by: Randall Spangler <rspangler@google.com>
Diffstat (limited to 'libnos_transport')
-rw-r--r--libnos_transport/transport.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libnos_transport/transport.c b/libnos_transport/transport.c
index 4d6034f..855b884 100644
--- a/libnos_transport/transport.c
+++ b/libnos_transport/transport.c
@@ -155,6 +155,10 @@ static int get_status(const struct transport_context *ctx,
uint8_t data[STATUS_MAX_LENGTH];
} st;
int retries = CRC_RETRY_COUNT;
+
+ /* All unset fields will be 0. */
+ memset(out, 0, sizeof(*out));
+
while (retries--) {
/* Get the status from the device */
const uint32_t command = CMD_ID(ctx->app_id) | CMD_IS_READ | CMD_TRANSPORT;
@@ -163,9 +167,6 @@ static int get_status(const struct transport_context *ctx,
return -1;
}
- /* All unset fields will be 0. */
- memset(out, 0, sizeof(*out));
-
/* Examine v0 fields */
out->status = le32toh(st.status.status);
out->reply_len = le16toh(st.status.reply_len);