]> git.pld-linux.org Git - projects/setup.git/commitdiff
Check write/close return values.
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Thu, 8 Dec 2011 09:14:22 +0000 (09:14 +0000)
committerArkadiusz Miśkiewicz <arekm@maven.pl>
Thu, 8 Dec 2011 09:14:22 +0000 (09:14 +0000)
Changed files:
    joinpasswd.c -> 1.11

joinpasswd.c

index c96ff0d5d021950eaadc42ebfde05cddb260b74c..b6a8250736189f2736e89a6f74528856cd39d00c 100644 (file)
@@ -174,8 +174,12 @@ int try_lock(const char *name)
        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);
This page took 0.106184 seconds and 4 git commands to generate.