diff options
author | Patrick Georgi <pgeorgi@google.com> | 2018-08-06 14:28:47 +0200 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-08-15 16:37:12 -0700 |
commit | 5012ca7804c594c763cc36ee93db1e90c118eac8 (patch) | |
tree | e7eb24aa679eda485833684e80e1d157ec194461 /util/ecst.c | |
parent | 2943eed83037dce551813cd50a05cdfb6380106e (diff) | |
download | chrome-ec-5012ca7804c594c763cc36ee93db1e90c118eac8.tar.gz |
util/ecst: Also report copy failure on writes
Change-Id: Ie01daa75b22fd1efca1c72d34c42c18abea53c2e
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Found-by: Coverity Scan #58172
Reviewed-on: https://chromium-review.googlesource.com/1163610
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@google.com>
Diffstat (limited to 'util/ecst.c')
-rwxr-xr-x | util/ecst.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/util/ecst.c b/util/ecst.c index e3544bbcaf..81dd76f7c7 100755 --- a/util/ecst.c +++ b/util/ecst.c @@ -1004,10 +1004,16 @@ int copy_file_to_file(char *dst_file_name, /* If byte reading pass than write it to the destination, */ /* else exit from the reading loop. */ - if (result) + if (result) { /* Read pass, so write it to destination file.*/ result = fwrite(&local_val, 1, 1, dst_file); - else + if (!result) + /* + * Write failed, + * return with the copied bytes number. + */ + break; + } else /* Read failed, return with the copied bytes number. */ break; } |