Dr. Werner Fink 2009-09-29 08:50:41 +00:00 committed by Git OBS Bridge
parent ade56f25f6
commit f690d3fe3f
2 changed files with 136 additions and 4 deletions

View File

@ -1,4 +1,130 @@
--- .dummy
+++ .dummy 2009-08-19 12:18:39.181901099 +0200
@@ -0,0 +1 @@
+this is a dummy, remove if real changes are required
--- libinit.c
+++ libinit.c 2009-09-29 10:42:09.875428620 +0200
@@ -446,9 +446,9 @@ static pid_t getpppid(const pid_t ppid)
goto out;
if ((fp = open(proc(pid, "stat"), O_PROCMODE)) != -1) {
- xread(fp, buf, BUFSIZ);
+ ssize_t len = xread(fp, buf, BUFSIZ);
close(fp);
- if (sscanf(buf,"%*d %*s %*c %d %*d %*d", &pppid) != 1)
+ if (len <= 0 || sscanf(buf,"%*d %*s %*c %d %*d %*d", &pppid) != 1)
warn("can not read ppid for process %d!\n", ppid);
}
out:
@@ -591,10 +591,11 @@ int pidof (const char * inname, const ch
char ent[3];
boolean thread;
ssize_t len;
+
len = xread(fp,ent,3);
close(fp);
- if (!len)
+ if (len <= 0)
continue;
thread = (strncmp(ent, "0 ", 2) == 0);
@@ -682,6 +683,9 @@ int pidof (const char * inname, const ch
len = xread(fp, entry, PATH_MAX);
close(fp);
+ if (len <= 0)
+ continue;
+
/* Seek for a script not for a binary */
if (!(scrpt = checkscripts(entry, root, len, d->d_name)))
continue;
@@ -713,7 +717,7 @@ int pidof (const char * inname, const ch
len = xread(fp, entry, PATH_MAX);
close(fp);
- if (!len)
+ if (len <= 0)
continue;
comm = index(entry, ' ');
@@ -764,7 +768,8 @@ int verify_pidfile (const char * pid_fil
const char * root, unsigned short flags,
const boolean ignore)
{
- int fp, cnt;
+ int fp;
+ ssize_t cnt;
boolean isscrpt = false;
pid_t pid;
char *swapname = NULL, *bufp;
@@ -789,11 +794,12 @@ int verify_pidfile (const char * pid_fil
}
errno = 0;
- if ((cnt = xread (fp, buf, BUFSIZ)) < 0) {
+ cnt = xread(fp, buf, BUFSIZ);
+ close(fp);
+ if (cnt < 0) {
warn("Can not read pid file %s: %s\n", pid_file, strerror(errno));
return -1;
}
- close(fp);
buf[cnt] = '\0';
bufp = buf;
@@ -847,10 +853,11 @@ int verify_pidfile (const char * pid_fil
char ent[3];
boolean thread;
ssize_t len;
+
len = xread(fp, ent, sizeof(ent));
close(fp);
- if (!len)
+ if (len <= 0)
goto out;
thread = (strncmp(ent, "0 ", 2) == 0);
@@ -932,6 +939,9 @@ int verify_pidfile (const char * pid_fil
len = xread(fp, entry, PATH_MAX);
close(fp);
+ if (len <= 0)
+ goto out;
+
/* Seek for a script not for a binary */
if (!(scrpt = checkscripts(entry, root, len, buf)))
goto out; /* Nothing found */
@@ -951,7 +961,7 @@ int verify_pidfile (const char * pid_fil
len = xread(fp, entry, PATH_MAX);
close(fp);
- if (!len)
+ if (len <= 0)
goto out;
comm = index(entry, ' ');
@@ -1040,7 +1050,7 @@ int check_pids (const char * inname, con
len = xread(fp, ent, sizeof(ent));
close(fp);
- if (!len)
+ if (len <= 0)
goto ignore; /* Bogus */
thread = (strncmp(ent, "0 ", 2) == 0);
@@ -1111,7 +1121,7 @@ int check_pids (const char * inname, con
len = xread(fp, entry, PATH_MAX);
close(fp);
- if (!len)
+ if (len <= 0)
goto ignore; /* Bogus */
/* Seek for a script not for a binary */
@@ -1131,7 +1141,7 @@ int check_pids (const char * inname, con
len = xread(fp, entry, PATH_MAX);
close(fp);
- if (!len)
+ if (len <= 0)
goto ignore; /* Bogus */
comm = index(entry, ' ');

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Sep 29 10:48:03 CEST 2009 - werner@suse.de
- Make killproc utils more stable in case that during read(2) a proc
file the corresponding process has already terminated (bnc#542717)
-------------------------------------------------------------------
Thu Aug 20 14:17:32 CEST 2009 - werner@suse.de