#include <sys/types.h>
#include <sys/stat.h>
-#include "../../list.h"
+#include "../../udev/list.h"
-#define TMPFILE "/dev/.udev/collect"
+#define TMPFILE UDEV_PREFIX "/dev/.udev/collect"
#define BUFSIZE 16
#define UDEV_ALARM_TIMEOUT 180
static int debug;
/* This can increase dynamically */
-static int bufsize = BUFSIZE;
+static size_t bufsize = BUFSIZE;
static void sig_alrm(int signo)
{
if (!ptr && word < (buf + len)) {
bufsize = bufsize << 1;
if (debug)
- fprintf(stderr, "ID overflow, restarting with size %d\n", bufsize);
+ fprintf(stderr, "ID overflow, restarting with size %zi\n", bufsize);
free(buf);
lseek(fd, 0, SEEK_SET);
goto restart;
ret++;
} else {
while (strlen(him->name)+1 >= bufsize) {
+ char *tmpbuf;
+
bufsize = bufsize << 1;
- buf = realloc(buf, bufsize);
+ tmpbuf = realloc(buf, bufsize);
+ if (!tmpbuf) {
+ free(buf);
+ return -1;
+ }
+ buf = tmpbuf;
}
snprintf(buf, strlen(him->name)+2, "%s ", him->name);
write(fd, buf, strlen(buf));