create_symref: check error return from open().
Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jan 26, 2007 at 17:00 UTC
8a56da29628997289aa8ec888ba85889962393e4
1 file changed
+5
-1
refs.c
+5
-1
@@ -331,7 +331,11 @@ int create_symref(const char *ref_target, const char *refs_heads_master)
331
return -1;
332
}
333
lockpath = mkpath("%s.lock", git_HEAD);
334
- fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666);
334
+ fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666);
335
+ if (fd < 0) {
336
+ error("Unable to open %s for writing", lockpath);
337
+ return -5;
338
+ }
339
written = write_in_full(fd, ref, len);
340
close(fd);
341
if (written != len) {