[PATCH] elfclassify: Handle fwrite to stdout failing.

Mark Wielaard mark@klomp.org
Sun Jul 19 17:41:22 GMT 2020


In theory an fwrite can fail, if so, signal it by calling issue ().

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 src/ChangeLog     | 4 ++++
 src/elfclassify.c | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 0129b8bf..fa7411fd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2020-07-19  Mark Wielaard  <mark@klomp.org>
+
+	* elfclassify.c (process_current_path): Handle fwrite failing.
+
 2020-06-16  Mark Wielaard  <mark@klomp.org>
 
 	* ar.c (do_oper_extract): Split large if statement. Call fchown
diff --git a/src/elfclassify.c b/src/elfclassify.c
index 535cc49f..624bb861 100644
--- a/src/elfclassify.c
+++ b/src/elfclassify.c
@@ -827,7 +827,8 @@ process_current_path (int *status)
       break;
     case do_print0:
       if (checks_passed == flag_print_matching)
-        fwrite (current_path, strlen (current_path) + 1, 1, stdout);
+        if (fwrite (current_path, strlen (current_path) + 1, 1, stdout) < 1)
+	  issue (errno, N_("writing to standard output"));
       break;
     case no_print:
       if (!checks_passed)
-- 
2.18.4



More information about the Elfutils-devel mailing list