--- sysklogd-1.4.2.orig/klogd.c 2006-10-17 22:39:21 +0000 +++ sysklogd-1.4.2/klogd.c 2006-10-17 23:21:55 +0000 @@ -994,7 +994,10 @@ int main(argc, argv) *output = (char *) 0; #ifndef TESTING - chdir ("/"); + if (chdir ("/") < 0) { + fprintf(stderr, "klogd: chdir to / failed: %m"); + exit(1); + } #endif /* Parse the command-line. */ while ((ch = getopt(argc, argv, "c:df:iIk:nopsvx2")) != EOF) --- sysklogd-1.4.2.orig/pidfile.c 2006-10-17 22:39:21 +0000 +++ sysklogd-1.4.2/pidfile.c 2006-10-17 23:21:55 +0000 @@ -45,7 +45,8 @@ int read_pid (char *pidfile) if (!(f=fopen(pidfile,"r"))) return 0; - fscanf(f,"%d", &pid); + if (fscanf(f, "%d", &pid) != 1) + pid = 0; fclose(f); return pid; } @@ -94,7 +95,8 @@ int write_pid (char *pidfile) } if (flock(fd, LOCK_EX|LOCK_NB) == -1) { - fscanf(f, "%d", &pid); + if (fscanf(f, "%d", &pid) != 1) + pid = 0; fclose(f); printf("Can't lock, lock is held by pid %d.\n", pid); return 0; --- sysklogd-1.4.2.orig/syslogd.c 2006-10-17 22:39:21 +0000 +++ sysklogd-1.4.2/syslogd.c 2006-10-17 23:22:33 +0000 @@ -676,8 +676,8 @@ struct filed { * in seconds after previous message is logged. After each flush, * we move to the next interval until we reach the largest. */ -int repeatinterval[] = { 30, 60 }; /* # of secs before flush */ -#define MAXREPEAT ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1) +time_t repeatinterval[] = { 30, 60 }; /* # of secs before flush */ +#define MAXREPEAT ((int) ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1)) #define REPEATTIME(f) ((f)->f_time + repeatinterval[(f)->f_repeatcount]) #define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \ (f)->f_repeatcount = MAXREPEAT; \ @@ -782,7 +782,7 @@ int main(int argc, char **argv); char **crunch_list(char *list); int usage(void); void untty(void); -void printchopped(const char *hname, char *msg, int len, int fd); +void printchopped(const char *hname, char *msg, size_t len, int fd); void printline(const char *hname, char *msg); void printsys(char *msg); void logmsg(int pri, char *msg, const char *from, int flags); @@ -825,7 +825,7 @@ int main(argc, argv) int len, num_fds; #else /* __GLIBC__ */ #ifndef TESTING - size_t len; + socklen_t len; #endif int num_fds; #endif /* __GLIBC__ */ @@ -861,7 +861,10 @@ int main(argc, argv) int maxfds; #ifndef TESTING - chdir ("/"); + if (chdir ("/") < 0) { + fprintf(stderr, "syslogd: chdir to / failed: %m"); + exit(1); + } #endif for (i = 1; i < MAXFUNIX; i++) { funixn[i] = ""; @@ -1399,7 +1402,7 @@ void untty() void printchopped(hname, msg, len, fd) const char *hname; char *msg; - int len; + size_t len; int fd; { auto int ptlngth; @@ -1409,7 +1412,7 @@ void printchopped(hname, msg, len, fd) *end, tmpline[MAXLINE + 1]; - dprintf("Message length: %d, File descriptor: %d.\n", len, fd); + dprintf("Message length: %lu, File descriptor: %d.\n", (unsigned long)len, fd); tmpline[0] = '\0'; if ( parts[fd] != (char *) 0 ) { @@ -1688,9 +1691,9 @@ void logmsg(pri, msg, from, flags) !strcmp(from, f->f_prevhost)) { (void) strncpy(f->f_lasttime, timestamp, 15); f->f_prevcount++; - dprintf("msg repeated %d times, %ld sec of %d.\n", + dprintf("msg repeated %d times, %ld sec of %ld.\n", f->f_prevcount, now - f->f_time, - repeatinterval[f->f_repeatcount]); + (long)repeatinterval[f->f_repeatcount]); /* * If domark would have logged this by now, * flush it now (so we don't hold isolated messages), @@ -2165,9 +2168,9 @@ void domark() for (f = Files; f; f = f->f_next) { #endif if (f->f_prevcount && now >= REPEATTIME(f)) { - dprintf("flush %s: repeated %d times, %d sec.\n", + dprintf("flush %s: repeated %d times, %ld sec.\n", TypeNames[f->f_type], f->f_prevcount, - repeatinterval[f->f_repeatcount]); + (long)repeatinterval[f->f_repeatcount]); fprintlog(f, LocalHostName, 0, (char *)NULL); BACKOFF(f); }