diff options
author | Bill Nottingham <notting@redhat.com> | 2004-11-16 06:24:23 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2004-11-16 06:24:23 +0000 |
commit | 8edc0537bebb743b31fb7aebc1c3d725aa998535 (patch) | |
tree | aa1000e5dad10fadbd13ec5fd2125a5c231f9b18 /src/minilogd.c | |
parent | ceeb7c028d5fd96b61f43734e3f7ea635459e1ed (diff) | |
download | initscripts-8edc0537bebb743b31fb7aebc1c3d725aa998535.tar initscripts-8edc0537bebb743b31fb7aebc1c3d725aa998535.tar.gz initscripts-8edc0537bebb743b31fb7aebc1c3d725aa998535.tar.bz2 initscripts-8edc0537bebb743b31fb7aebc1c3d725aa998535.tar.xz initscripts-8edc0537bebb743b31fb7aebc1c3d725aa998535.zip |
fix various minilogd bogosities (uninitialized variable, handling of wrong-protocol connections, don't check atime) (#106338)
Diffstat (limited to 'src/minilogd.c')
-rw-r--r-- | src/minilogd.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/minilogd.c b/src/minilogd.c index 90bce3f8..b8eaa109 100644 --- a/src/minilogd.c +++ b/src/minilogd.c @@ -69,7 +69,8 @@ void cleanup(int exitcode) { void runDaemon(int sock) { struct sockaddr_un addr; - int x,len,addrlen,done=0; + int x,len,done=0; + int addrlen = sizeof(struct sockaddr_un); char *message; struct stat s1,s2; struct pollfd pfds; @@ -101,10 +102,13 @@ void runDaemon(int sock) { } if ( (x>0) && pfds.revents & (POLLIN | POLLPRI)) { message = calloc(8192,sizeof(char)); + addrlen = sizeof(struct sockaddr_un); recvsock = accept(sock,(struct sockaddr *) &addr, &addrlen); + if (recvsock == -1) + continue; alarm(2); signal(SIGALRM, alarm_handler); - len = read(recvsock,message,8192); + len = recv(recvsock,message,8192,0); alarm(0); close(recvsock); if (len>0) { @@ -127,7 +131,7 @@ void runDaemon(int sock) { /* Check to see if syslogd's yanked our socket out from under us */ if ( (stat(_PATH_LOG,&s2)!=0) || (s1.st_ino != s2.st_ino ) || (s1.st_ctime != s2.st_ctime) || - (s1.st_mtime != s2.st_mtime) || (s1.st_atime != s2.st_atime) ) { + (s1.st_mtime != s2.st_mtime) ) { done = 1; we_own_log = 0; } |