summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Ratiu <adrian.ratiu@collabora.corp-partner.google.com>2021-01-22 18:34:40 +0200
committerCommit Bot <commit-bot@chromium.org>2021-01-22 18:07:43 +0000
commit8b79ea5638d5986155a5fccc8ca94628c8814919 (patch)
treea9c3366a5e14e940607cccd47a31b385d1125362
parent72a3dd167c24a20a6df568d0c84c77dd45a6d2cf (diff)
downloadchrome-ec-8b79ea5638d5986155a5fccc8ca94628c8814919.tar.gz
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 <adrian.ratiu@collabora.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2645125 Tested-by: Adrian Ratiu <adrian.ratiu@collabora.corp-partner.google.com> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--extra/usb_updater/gsctool.c2
1 files changed, 1 insertions, 1 deletions
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,