matanp has uploaded this change for review.

View Change

rest_api: Fix encoded payload length check

Change-Id: I4224102dd924dfded59e3a489079d02ca0237983
---
M src/rest_api.c
1 file changed, 3 insertions(+), 2 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-cbc refs/changes/97/41997/1
diff --git a/src/rest_api.c b/src/rest_api.c
index 3af50e6..6834dca 100644
--- a/src/rest_api.c
+++ b/src/rest_api.c
@@ -348,8 +348,9 @@
return -EINVAL;
}
hexstr = json_string_value(jpage);
- if (strlen(hexstr) > 88 * 2) {
- *errstr = "'pages' array must contain strings up to 88 hex nibbles";
+ /* The total page length is 88, but the header is 6 bytes length */
+ if (strlen(hexstr) > sizeof(out->cbs.data[i]) * 2) {
+ *errstr = "'pages' actual data array must contain strings up to 82 hex nibbles";
return -EINVAL;
}
len = osmo_hexparse(hexstr, out->cbs.data[i], sizeof(out->cbs.data[i]));

To view, visit change 41997. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-cbc
Gerrit-Branch: master
Gerrit-Change-Id: I4224102dd924dfded59e3a489079d02ca0237983
Gerrit-Change-Number: 41997
Gerrit-PatchSet: 1
Gerrit-Owner: matanp <matan1008@gmail.com>