From 5012ca7804c594c763cc36ee93db1e90c118eac8 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Mon, 6 Aug 2018 14:28:47 +0200 Subject: util/ecst: Also report copy failure on writes Change-Id: Ie01daa75b22fd1efca1c72d34c42c18abea53c2e Signed-off-by: Patrick Georgi Found-by: Coverity Scan #58172 Reviewed-on: https://chromium-review.googlesource.com/1163610 Commit-Ready: Patrick Georgi Tested-by: Patrick Georgi Reviewed-by: Stefan Reinauer --- util/ecst.c | 10 ++++++++-- 1 file 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; } -- cgit v1.2.1