Thread (4 messages) flat view 4 messages, 2 authors, 2016-06-15

Re: [PATCH] Fix segmentation fault when user doesn't have access permission to the repository.

From: Alex Riesen <hidden>
Date: 2016-06-15 22:43:53

André Goddard Rosa, Thu, Nov 22, 2007 01:59:00 +0100:
quoted hunk ↗ jump to hunk
@@ -487,8 +490,13 @@ static int do_fetch(struct transport *transport,
 		die("Don't know how to fetch from %s", transport->url);
 
 	/* if not appending, truncate FETCH_HEAD */
-	if (!append)
-		fclose(fopen(git_path("FETCH_HEAD"), "w"));
+	if (!append) {
+		char *filename = git_path("FETCH_HEAD");
+		int fd = fopen(filename, "w");
This should have been "FILE *fp", not "int fd".
+		if (!fd)
+			return error("cannot open %s: %s\n", filename, strerror(errno));
+		fclose(fd);
+	}
 
 	ref_map = get_ref_map(transport, refs, ref_count, tags, &autotags);
 
-- 
1.5.3.6.861.gd794-dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help