summaryrefslogtreecommitdiff
path: root/util/nvramtool/cli
diff options
context:
space:
mode:
authorPatrick Georgi <patrick@georgi-clan.de>2014-08-09 17:02:00 +0200
committerPatrick Georgi <patrick@georgi-clan.de>2014-08-10 08:20:09 +0200
commitc5d179123df5e7d8b72e613935b9e1bd278886f9 (patch)
tree1022f0d6efceef1b0aee25e80f8b8ea86b1ed4f8 /util/nvramtool/cli
parentb6239b81aa3a3ac9cb08aa70d1f1179e1619f429 (diff)
downloadcoreboot-c5d179123df5e7d8b72e613935b9e1bd278886f9.tar.xz
nvramtool: check for successful seek
Otherwise the following write might end up anywhere. Change-Id: Ie42d984824e9308bd58b8bb905b6ea823543adf0 Found-by: Coverity Scan Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/6560 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util/nvramtool/cli')
-rw-r--r--util/nvramtool/cli/nvramtool.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/util/nvramtool/cli/nvramtool.c b/util/nvramtool/cli/nvramtool.c
index d5acc5838e..bdfaaff26d 100644
--- a/util/nvramtool/cli/nvramtool.c
+++ b/util/nvramtool/cli/nvramtool.c
@@ -163,8 +163,8 @@ int main(int argc, char *argv[])
}
if (fd_stat.st_size < CMOS_SIZE) {
- lseek(fd, CMOS_SIZE - 1, SEEK_SET);
- if (write(fd, "\0", 1) != 1) {
+ if ((lseek(fd, CMOS_SIZE - 1, SEEK_SET) == -1) ||
+ (write(fd, "\0", 1) != 1)) {
fprintf(stderr, "Unable to extended '%s' to its full size.\n",
nvramtool_op_modifiers[NVRAMTOOL_MOD_USE_CMOS_FILE].param);
exit(1);