diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-07-11 10:21:49 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-13 15:46:35 +0000 |
commit | c8282f61e105490ed50120ec2d6a83a1e2ec1e08 (patch) | |
tree | 73047f4ef11b26e46ef90795a1c74c3c03932394 /board/hammer/board.c | |
parent | cce493a388878334a65af95c4313ee051ef8a546 (diff) | |
download | chrome-ec-c8282f61e105490ed50120ec2d6a83a1e2ec1e08.tar.gz |
tree: Check return value from snprintf
snprintf returns a negative value on failure. The return value should be
checked to make sure that there were no errors.
BRANCH=none
BUG=b:238433667, b:234181908
TEST=make buildall
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I64e2e69df7fa22c94f19acbbca8c6afbe6cf1ff1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3756174
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'board/hammer/board.c')
-rw-r--r-- | board/hammer/board.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/board/hammer/board.c b/board/hammer/board.c index 12cf41e910..76a4df7eeb 100644 --- a/board/hammer/board.c +++ b/board/hammer/board.c @@ -322,7 +322,9 @@ __override const char *board_read_serial(void) int i; for (i = 0; i < idlen && pos < sizeof(str); i++, pos += 2) { - snprintf(&str[pos], sizeof(str) - pos, "%02x", id[i]); + if (snprintf(&str[pos], sizeof(str) - pos, "%02x", + id[i]) < 0) + return NULL; } } |