]> err.no Git - systemd/commitdiff
collect: realloc buffer, if needed
authorXinwei Hu <hxinwei@gmail.com>
Tue, 27 May 2008 17:35:03 +0000 (19:35 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Tue, 27 May 2008 17:35:03 +0000 (19:35 +0200)
extras/collect/collect.c

index 0a852f2db239b2d4050a3ec3b90371c273ddf3ee..feb0e7576871551e6e5984c32a0e43d51a79b9dc 100644 (file)
@@ -271,7 +271,11 @@ static int missing(int fd)
                if (him->state == STATE_NONE) {
                        ret++;
                } else {
-                       sprintf(buf, "%s ", him->name);
+                       while (strlen(him->name)+1 >= bufsize) {
+                               bufsize = bufsize << 1;
+                               buf = realloc(buf, bufsize);
+                       }
+                       snprintf(buf, strlen(him->name)+2, "%s ", him->name);
                        write(fd, buf, strlen(buf));
                }
        }