Package: userv

[pseudo-header added by iwj]

Hi,

Please find a patch, attached, to address some minor compilation issues as well as adding error checking for readdir().

Peter
diff -wur userv-1.0.3.orig/both.c userv-1.0.3-pjb/both.c
--- userv-1.0.3.orig/both.c	1999-10-10 12:39:46.000000000 +0100
+++ userv-1.0.3-pjb/both.c	2016-06-15 19:41:21.946598285 +0100
@@ -29,6 +29,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <errno.h>
 
 #include "config.h"
diff -wur userv-1.0.3.orig/lexer.l.m4 userv-1.0.3-pjb/lexer.l.m4
--- userv-1.0.3.orig/lexer.l.m4	1999-11-07 15:39:53.000000000 +0000
+++ userv-1.0.3-pjb/lexer.l.m4	2016-06-15 20:02:52.422382569 +0100
@@ -134,11 +134,12 @@
 static int dequote(char *inplace);
 static void countnewlines(void);
 
-#define YY_NO_UNPUT
+#define YY_NO_INPUT
 
 %}
 
 %option noyywrap
+%option nounput
 
 %%
 
diff -wur userv-1.0.3.orig/overlord.c userv-1.0.3-pjb/overlord.c
--- userv-1.0.3.orig/overlord.c	1999-05-20 00:13:54.000000000 +0100
+++ userv-1.0.3-pjb/overlord.c	2016-06-15 19:42:43.110840736 +0100
@@ -25,6 +25,7 @@
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <assert.h>
 #include <fnmatch.h>
 #include <sys/wait.h>
@@ -67,7 +68,7 @@
   if (time(&now) == -1) { syslog(LOG_ERR,"get current time: %m"); return; }
   dir= opendir(".");
   if (!dir) { syslog(LOG_ERR,"open directory " VARDIR ": %m"); return; }
-  while ((de= readdir(dir))) {
+  while ((errno=0, de= readdir(dir))) {
     if (fnmatch(PIPEPATTERN,de->d_name,FNM_PATHNAME|FNM_PERIOD)) continue;
     r= lstat(de->d_name,&stab); if (r && errno==ENOENT) continue;
     if (r) { syslog(LOG_ERR,"could not stat `" VARDIR "/%s': %m",de->d_name); continue; }
@@ -76,6 +77,7 @@
     if (unlink(de->d_name) && errno!=ENOENT)
       syslog(LOG_ERR,"could not remove stale pipe `%s': %m",de->d_name);
   }
+  if (errno) syslog(LOG_ERR,"read directory " VARDIR ": %m");
   if (closedir(dir)) syslog(LOG_ERR,"close directory " VARDIR ": %m");
 }
 
@@ -263,7 +265,8 @@
 }
 
 int main(int argc, char *const *argv) {
-  int mfd, sfd, nfd, csocklen, e, r, becomedaemon;
+  int mfd, sfd, nfd, e, r, becomedaemon;
+  socklen_t csocklen;
   struct sigaction sigact;
   struct sockaddr_un ssockname, csockname;
   pid_t child, parentpid, sid;
diff -wur userv-1.0.3.orig/parser.c userv-1.0.3-pjb/parser.c
--- userv-1.0.3.orig/parser.c	2003-11-01 01:02:14.000000000 +0000
+++ userv-1.0.3-pjb/parser.c	2016-06-15 20:01:15.346102683 +0100
@@ -995,7 +995,7 @@
     return parseerrprint("unable to open directory `%s': %s",cpget,strerror(errno));
   cp= xstrsave(cpget);
   cpl= strlen(cp);
-  while ((de= readdir(d))) {
+  while ((errno=0, de= readdir(d))) {
     tel= strlen(de->d_name);
     if (!tel) continue;
     p= de->d_name;
@@ -1014,6 +1014,12 @@
       goto x_err;
     }
   }
+  if (errno) {
+    parseerrprint("error reading directory `%s': %s",cp,strerror(errno));
+    closedir(d);
+    free(cp);
+    return tokv_error;
+  }
   if (closedir(d)) {
     parseerrprint("error closing directory `%s': %s",cp,strerror(errno));
     free(cp);

Reply via email to