From 14c01ac6c6e80b37e38c8b34d07e8501084ba2a8 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Fri, 20 Sep 2019 21:35:17 +0200 Subject: futility: also clamp to natural values Found by Coverity Scan #242 BUG=none BRANCH=none TEST=none Change-Id: I384044d36ee5e2e9d344c7af40d61c5e27fd75b4 Signed-off-by: Patrick Georgi Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1815239 Reviewed-by: Hung-Te Lin Tested-by: Patrick Georgi Commit-Queue: Patrick Georgi --- futility/updater.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/futility/updater.c b/futility/updater.c index 07d2d668..b17fe936 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -236,9 +236,11 @@ static int host_get_platform_version(void) if (strncmp(result, STR_REV, strlen(STR_REV)) == 0) rev = strtol(result + strlen(STR_REV), NULL, 0); - /* we should never have that large versions, + /* we should never have negative or extremely large versions, * but clamp just to be sure */ + if (rev < 0) + rev = 0; if (rev > INT_MAX) rev = INT_MAX; -- cgit v1.2.1