From 8b79ea5638d5986155a5fccc8ca94628c8814919 Mon Sep 17 00:00:00 2001 From: Adrian Ratiu Date: Fri, 22 Jan 2021 18:34:40 +0200 Subject: usb_updater: gsctool: fix buffer truncation warn/error GCC starting with v7 introduced a new warning triggered by the snprintf calls which fails the build due to having -Werror on. CrOS is upgrading GCC 4.9 -> 10.2. The fix here is to increase the buffer size a bit so the entire max string content can fit into the buffer, thus not triggering GCC's bounds checks. gsctool.c: In function 'process_erase_ap_ro_hash': gsctool.c:1540:37: error: ', size ' directive output truncated writing 7 bytes into a region of size between 0 and 2 [-Werror=format-truncation=] 1540 | "misconfigured response, rc=%d, size %zd", | ~~^~~~~ gsctool.c:1540:5: note: using the range [-..., ...] for directive argument 1540 | "misconfigured response, rc=%d, size %zd", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gsctool.c:1539:3: note: 'snprintf' output between 37 and 66 bytes into a destination of size 30 1539 | snprintf(error_details, sizeof(error_details), | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1540 | "misconfigured response, rc=%d, size %zd", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1541 | rv, response_size); | ~~~~~~~~~~~~~~~~~~ gsctool.c:1534:38: error: ', response ' directive output truncated writing 11 bytes into a region of size between 0 and 9 [-Werror=format-truncation=] 1534 | "Unexpected error rc %d, response %d", | ~~~~~~~~~^~ gsctool.c:1533:4: note: 'snprintf' output between 34 and 46 bytes into a destination of size 30 1533 | snprintf(error_details, sizeof(error_details), | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1534 | "Unexpected error rc %d, response %d", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1535 | rv, response); | ~~~~~~~~~~~~~ cc1: all warnings being treated as errors BUG=chromium:1169162 TEST=Local builds using GCC 10.2.0. Change-Id: Ib66eb6a877c52a8bd6e82a7e76d040ff927ec691 Signed-off-by: Adrian Ratiu Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2645125 Tested-by: Adrian Ratiu Commit-Queue: Vadim Bendebury Reviewed-by: Vadim Bendebury --- extra/usb_updater/gsctool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'extra/usb_updater') diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c index 0bab49cf88..f4e6cb4692 100644 --- a/extra/usb_updater/gsctool.c +++ b/extra/usb_updater/gsctool.c @@ -1509,7 +1509,7 @@ static void process_erase_ap_ro_hash(struct transfer_descriptor *td) uint32_t rv; uint8_t response; size_t response_size; - char error_details[30]; + char error_details[64]; response_size = sizeof(response); rv = send_vendor_command(td, VENDOR_CC_SEED_AP_RO_CHECK, -- cgit v1.2.1