public inbox for debugedit@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] debugedit: check write to list_file succeeds
@ 2021-07-01 15:17 Mark Wielaard
  2021-07-05 14:39 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2021-07-01 15:17 UTC (permalink / raw)
  To: debugedit; +Cc: Mark Wielaard

We didn't check, or ignored, errors writing to the list_file. Always
produce an error if we cannot write to the list_file.

	* debugedit.c (read_dwarf4_line): Produce error if write fails.
	(read_dwarf5_line_entries): Likewise.
	(edit_attributes): Likewise.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 tools/debugedit.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tools/debugedit.c b/tools/debugedit.c
index 80b99fe..f07b6e1 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -1785,7 +1785,7 @@ read_dwarf4_line (DSO *dso, unsigned char *ptr, char *comp_dir,
 		{
 		  ssize_t ret = write (list_file_fd, p, size);
 		  if (ret == -1)
-		    break;
+		    error (1, errno, "Could not write to '%s'", list_file);
 		  size -= ret;
 		  p += ret;
 		}
@@ -2005,7 +2005,7 @@ read_dwarf5_line_entries (DSO *dso, unsigned char **ptrp,
 		    {
 		      ssize_t ret = write (list_file_fd, p, size);
 		      if (ret == -1)
-			break;
+			error (1, errno, "Could not write to '%s'", list_file);
 		      size -= ret;
 		      p += ret;
 		    }
@@ -2348,7 +2348,7 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
 	    {
 	      ssize_t ret = write (list_file_fd, p, size);
 	      if (ret == -1)
-		break;
+		error (1, errno, "Could not write to '%s'", list_file);
 	      size -= ret;
 	      p += ret;
 	    }
@@ -2356,10 +2356,13 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
 	     regular files. */
 	  if (size == 0)
 	    {
+	      ssize_t ret;
 	      if (*(p - 1) != '/')
-		write (list_file_fd, "/", 2);
+		ret = write (list_file_fd, "/", 2);
 	      else
-		write (list_file_fd, "", 1);
+		ret = write (list_file_fd, "", 1);
+	      if (ret == -1)
+		error (1, errno, "Could not write to '%s'", list_file);
 	    }
 	}
     }
-- 
2.32.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] debugedit: check write to list_file succeeds
  2021-07-01 15:17 [PATCH] debugedit: check write to list_file succeeds Mark Wielaard
@ 2021-07-05 14:39 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2021-07-05 14:39 UTC (permalink / raw)
  To: debugedit

Hi,

On Thu, 2021-07-01 at 17:17 +0200, Mark Wielaard wrote:
> We didn't check, or ignored, errors writing to the list_file. Always
> produce an error if we cannot write to the list_file.

I pushed this and the other cleanups I posted last Thursday to main.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-05 14:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01 15:17 [PATCH] debugedit: check write to list_file succeeds Mark Wielaard
2021-07-05 14:39 ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).