aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArve Hjønnevåg <arve@android.com>2023-10-10 13:25:19 -0700
committerArve Hjønnevåg <arve@android.com>2024-03-15 17:31:23 +0000
commit4d5474d57372c9d8a9f57c01bda52d806bdd9aaf (patch)
tree865d6c08c07d753eb55c9cf007acd5ace37c1a03
parent91c61110b370de3cad269a6fed39b3c6c184500b (diff)
downloadstorage-4d5474d57372c9d8a9f57c01bda52d806bdd9aaf.tar.gz
storage: Return error from rpmb_send on short reads
If the response packet is truncated, return an error code so we get a clearer error message than having the rpmb layer complain about the content in the uninialized repsonse data. Bug: 304582473 Change-Id: If201b5d0950371f8f276546e25087343419635e7
-rw-r--r--tipc_ns.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/tipc_ns.c b/tipc_ns.c
index 76d38aa..c5a3fb3 100644
--- a/tipc_ns.c
+++ b/tipc_ns.c
@@ -119,7 +119,20 @@ int rpmb_send(void* handle_,
return rc;
}
- return check_response(STORAGE_RPMB_SEND, &msg, rc);
+ size_t bytes_read = (size_t)rc;
+
+ rc = check_response(STORAGE_RPMB_SEND, &msg, bytes_read);
+ if (rc != NO_ERROR) {
+ return rc;
+ }
+
+ if (bytes_read != sizeof(msg) + read_size) {
+ SS_ERR("%s: rpmb send failed, invalid response size (%zu != %zu + %zu)\n",
+ __func__, bytes_read, sizeof(msg), read_size);
+ return ERR_NOT_VALID;
+ }
+
+ return NO_ERROR;
}
int ns_open_file(handle_t ipc_handle,