From: Junio C Hamano Date: Sat, 27 Jan 2007 01:00:57 +0000 (-0800) Subject: create_symref: check error return from open(). X-Git-Tag: v1.5.0-rc3~46 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8a56da29628997289aa8ec888ba85889962393e4;p=git.git create_symref: check error return from open(). Signed-off-by: Junio C Hamano --- diff --git a/refs.c b/refs.c index 0840b3bab..12e46b8bb 100644 --- a/refs.c +++ b/refs.c @@ -331,7 +331,11 @@ int create_symref(const char *ref_target, const char *refs_heads_master) return -1; } lockpath = mkpath("%s.lock", git_HEAD); - fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666); + fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666); + if (fd < 0) { + error("Unable to open %s for writing", lockpath); + return -5; + } written = write_in_full(fd, ref, len); close(fd); if (written != len) {