git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[Patch v2 1/2] bugreport.c: replace strbuf_write_fd with write_in_full

From
Rrandall.s.becker@rogers.com <randall.s.becker@rogers.com>
Date
Jun 19, 2020, 20:23 UTC
Message-ID
<20200619202320.4619-2-randall.s.becker@rogers.com>
In-Reply-To
<20200619202320.4619-1-randall.s.becker@rogers.com>
From: "Randall S. Becker" <randall.becker@nexbridge.ca>

The strbuf_write_fd method did not provide checks for buffers larger than MAX_IO_SIZE. Replacing with write_in_full ensures the entire buffer will always be written to disk or report an error and die.

Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com>
---
 bugreport.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/bugreport.c b/bugreport.c
index aa8a489c35..1aefa4c6bc 100644
--- a/bugreport.c
+++ b/bugreport.c
@@ -174,7 +174,9 @@ int cmd_main(int argc, const char **argv)
 		die(_("couldn't create a new file at '%s'"), report_path.buf);
 	}
 
-	strbuf_write_fd(&buffer, report);
+	if (write_in_full(report, buffer.buf, buffer.len) < 0)
+		die_errno(_("unable to write to %s"), report_path.buf);
+
 	close(report);
 
 	/*
-- 
2.21.0
Previous: randall.s.becker@rogers.comNext: randall.s.becker@rogers.com
Message 2 of 4 in “Replace strbuf_write_fd with write_in_full”
  1. 0/2 Replace strbuf_write_fd with write_in_fullrandall.s.becker@rogers.com, Jun 19, 2020
  2. 1/2 bugreport.c: replace strbuf_write_fd with write_in_fullrandall.s.becker@rogers.com, Jun 19, 2020
  3. 2/2 strbuf: remove unreferenced strbuf_write_fd method.randall.s.becker@rogers.com, Jun 19, 2020
  4. Junio C HamanoJun 19, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.