Re: [cgit PATCH] Close file descriptor on error in readfile()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steven Noonan wrote:
The above change looks bogus. If fd == -1, you close() it anyway?
Ah, of course, sorry.  I'll redo the patch.
+    if (fstat(fd, &st)) {
+        close(fd);
       return errno;
+    }
   if (!S_ISREG(st.st_mode))
       return EISDIR;
   *buf = xmalloc(st.st_size + 1);
   *size = read_in_full(fd, *buf, st.st_size);
   (*buf)[*size] = '\0';
+    close(fd);
   return (*size == st.st_size ? 0 : errno);
}
--
1.6.5.2
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4580 (20091106) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]