git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bundle, fast-import: detect write failure
@ 2008-01-10  8:54 Jim Meyering
  2008-01-10  9:17 ` Pierre Habouzit
  2008-01-10 12:05 ` Johannes Schindelin
  0 siblings, 2 replies; 13+ messages in thread
From: Jim Meyering @ 2008-01-10  8:54 UTC (permalink / raw)
  To: git list


I noticed some unchecked writes.  This fixes them.

* bundle.c (create_bundle): Die upon write failure.
* fast-import.c (keep_pack): Die upon write or close failure.

Signed-off-by: Jim Meyering <meyering@redhat.com>
---
 bundle.c      |    6 +++---
 fast-import.c |    5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/bundle.c b/bundle.c
index be204d8..316aa74 100644
--- a/bundle.c
+++ b/bundle.c
@@ -320,9 +320,9 @@ int create_bundle(struct bundle_header *header, const char *path,
 	for (i = 0; i < revs.pending.nr; i++) {
 		struct object *object = revs.pending.objects[i].item;
 		if (object->flags & UNINTERESTING)
-			write(rls.in, "^", 1);
-		write(rls.in, sha1_to_hex(object->sha1), 40);
-		write(rls.in, "\n", 1);
+			write_or_die(rls.in, "^", 1);
+		write_or_die(rls.in, sha1_to_hex(object->sha1), 40);
+		write_or_die(rls.in, "\n", 1);
 	}
 	if (finish_command(&rls))
 		return error ("pack-objects died");
diff --git a/fast-import.c b/fast-import.c
index 74597c9..82e9161 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -878,8 +878,9 @@ static char *keep_pack(char *curr_index_name)
 	keep_fd = open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
 	if (keep_fd < 0)
 		die("cannot create keep file");
-	write(keep_fd, keep_msg, strlen(keep_msg));
-	close(keep_fd);
+	write_or_die(keep_fd, keep_msg, strlen(keep_msg));
+	if (close(keep_fd))
+		die("failed to write keep file");

 	snprintf(name, sizeof(name), "%s/pack/pack-%s.pack",
 		 get_object_directory(), sha1_to_hex(pack_data->sha1));
--
1.5.4.rc2.85.g71fd

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

end of thread, other threads:[~2008-01-11 11:40 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-10  8:54 [PATCH] bundle, fast-import: detect write failure Jim Meyering
2008-01-10  9:17 ` Pierre Habouzit
2008-01-10 12:05 ` Johannes Schindelin
2008-01-10 12:26   ` Jim Meyering
2008-01-10 12:37     ` Johannes Schindelin
2008-01-10 13:00       ` Jim Meyering
2008-01-10 16:25         ` Pierre Habouzit
2008-01-10 18:05           ` Jim Meyering
2008-01-10 18:18             ` Pierre Habouzit
2008-01-11  9:14           ` Jakub Narebski
2008-01-11  7:36         ` Junio C Hamano
2008-01-11  9:37           ` David Tweed
2008-01-11 11:39           ` Johannes Schindelin

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 NNTP newsgroup(s).