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>
This commit is contained in:
Patrick Georgi 2014-08-09 17:02:00 +02:00
parent b6239b81aa
commit c5d179123d
1 changed files with 2 additions and 2 deletions

View File

@ -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);