Skip to content

Commit

Permalink
check n in resize function
Browse files Browse the repository at this point in the history
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
  • Loading branch information
dirk-thomas committed May 2, 2019
1 parent 5150096 commit 308c68c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rosidl_generator_c/src/u16string_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ rosidl_generator_c__U16String__resize(
if (!str) {
return false;
}
// check valid range of n before allocating n + 1 characters
if (n > SIZE_MAX / sizeof(uint16_t) - 1) {
return false;
}
uint16_t * data = realloc(str->data, (n + 1) * sizeof(uint16_t));
if (!data) {
return false;
Expand Down

0 comments on commit 308c68c

Please sign in to comment.