Skip to content

Commit 0c65f01

Browse files
committed
Fix integer overflow in URI parsing
If an ID exeeds the max. possible value we return early with an error instead of continuing and checking for too big values at the end.
1 parent ee15fb9 commit 0c65f01

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

core/uri.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ static int prv_parseNumber(uint8_t * uriString,
7171
{
7272
result *= 10;
7373
result += uriString[*headP] - '0';
74+
if (result > LWM2M_MAX_ID) {
75+
return -1;
76+
}
7477
}
7578
else
7679
{
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
add_fuzzing_test(TARGET_NAME fuz_registration_handleRequest SOURCE_FILES fuz_registration_handleRequest.c)
1+
add_fuzzing_test(
2+
TARGET_NAME fuz_registration_handleRequest
3+
SOURCE_FILES fuz_registration_handleRequest.c
4+
CRASH_FILES_DIR crash_files/
5+
)
26
# workaround to be able to test private functions
37
target_include_directories(fuz_registration_handleRequest PRIVATE ../../coap ../../core)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
</37777777777>/>/

0 commit comments

Comments
 (0)