chiark / gitweb /
udev: collect - use snprintf()
[elogind.git] / src / udev / collect / collect.c
index 47c2ddd63e510424230bdddc4059768252009efc..3c46e40de11cb84de379957b5163d981aaefa5f8 100644 (file)
@@ -93,7 +93,7 @@ static int prepare(char *dir, char *filename)
         if (stat(dir, &statbuf) < 0)
                 mkdir(dir, 0700);
 
-        sprintf(buf, "%s/%s", dir, filename);
+        snprintf(buf, sizeof(buf), "%s/%s", dir, filename);
 
         fd = open(buf,O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
         if (fd < 0)
@@ -305,7 +305,10 @@ static int missing(int fd)
                                 buf = tmpbuf;
                         }
                         snprintf(buf, strlen(him->name)+2, "%s ", him->name);
-                        write(fd, buf, strlen(buf));
+                        if (write(fd, buf, strlen(buf)) < 0) {
+                                free(buf);
+                                return -1;
+                        }
                 }
         }