setup: joinpasswd.c Check write/close return values.

arekm arekm at pld-linux.org
Thu Dec 8 10:14:27 CET 2011


Author: arekm                        Date: Thu Dec  8 09:14:27 2011 GMT
Module: setup                         Tag: HEAD
---- Log message:
Check write/close return values.

---- Files affected:
setup:
   joinpasswd.c (1.10 -> 1.11) 

---- Diffs:

================================================================
Index: setup/joinpasswd.c
diff -u setup/joinpasswd.c:1.10 setup/joinpasswd.c:1.11
--- setup/joinpasswd.c:1.10	Sat Feb 21 19:26:15 2009
+++ setup/joinpasswd.c	Thu Dec  8 10:14:22 2011
@@ -174,8 +174,12 @@
 	fd = open(file, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0600);
 	if (fd < 0)
 		return -1;
-	write(fd, buf, strlen(buf));
-	close(fd);
+	if (write(fd, buf, strlen(buf)) < 0) {
+		close(fd);
+		return -1;
+	}
+	if (close(fd) < 0)
+		return -1;
 
 	if (link(file, lock) == 0) {
 		unlink(file);
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/setup/joinpasswd.c?r1=1.10&r2=1.11&f=u



More information about the pld-cvs-commit mailing list