Skip to content

Commit

Permalink
Update #435, add upper bound check to snprintf return
Browse files Browse the repository at this point in the history
  • Loading branch information
jphickey committed May 11, 2020
1 parent a227f3b commit 6175171
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/unit-tests/inc/ut_os_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static inline bool UtOsalImplemented(int32 Fn, const char *File, uint32 Line)
/*--------------------------------------------------------------------------------*/

#define UT_os_sprintf(buf,...) \
do { int x = snprintf(buf,sizeof(buf),__VA_ARGS__); if (x > 0) buf[x] = 0; } while (0)
do { int x = snprintf(buf,sizeof(buf),__VA_ARGS__); if (x > 0 && x < sizeof(buf)) buf[x] = 0; } while (0)

/*--------------------------------------------------------------------------------*/

Expand Down

0 comments on commit 6175171

Please sign in to comment.