-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typecasting causing undefined behavior #429
Labels
Comments
sbertin-telular
added a commit
to sbertin-telular/wakaama
that referenced
this issue
Feb 22, 2019
size_t can be 64-bits while unsigned int is smaller. This causes issues when option_length is accessed through the pointer x in coap_parse_message(). The option length and delta are at most a 16-bit unsigned integer plus 269 according to RFC 7252. Changing option_number, option_delta, and option_length to uint32_t and x to uint32_t * fixes eclipse-wakaama#429. This also ensures sufficient size even if used on a platform with smaller integers. Signed-off-by: Scott Bertin <[email protected]>
sbertin-telular
added a commit
to sbertin-telular/wakaama
that referenced
this issue
Nov 12, 2020
size_t can be 64-bits while unsigned int is smaller. This causes issues when option_length is accessed through the pointer x in coap_parse_message(). The option length and delta are at most a 16-bit unsigned integer plus 269 according to RFC 7252. Changing option_number, option_delta, and option_length to uint32_t and x to uint32_t * fixes eclipse-wakaama#429. This also ensures sufficient size even if used on a platform with smaller integers. Signed-off-by: Scott Bertin <[email protected]>
sbertin-telular
added a commit
to sbertin-telular/wakaama
that referenced
this issue
Nov 13, 2020
size_t can be 64-bits while unsigned int is smaller. This causes issues when option_length is accessed through the pointer x in coap_parse_message(). The option length and delta are at most a 16-bit unsigned integer plus 269 according to RFC 7252. Changing option_number, option_delta, and option_length to uint32_t and x to uint32_t * fixes eclipse-wakaama#429. This also ensures sufficient size even if used on a platform with smaller integers. Signed-off-by: Scott Bertin <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In er-coap-13.c there is the following code:
Both
option_delta
andx
are of typeunsigned int
, whileoption_length
is of typesize_t
. In some systems these types are of different sizes, thus such code causes undefined behavior. My suggestion would be to change the type ofoption_length
tounsigned int
.The text was updated successfully, but these errors were encountered: