psmisc/psmisc-22.3-killall-ino.patch
2007-04-02 11:44:38 +00:00

38 lines
992 B
Diff

--- psmisc-22.3/src/killall.c.kzak 2007-04-02 11:45:04.000000000 +0200
+++ psmisc-22.3/src/killall.c 2007-04-02 12:56:54.000000000 +0200
@@ -372,16 +372,29 @@
}
else
{
+ int ok = 1;
+
if (asprintf (&path, PROC_BASE "/%d/exe", pid_table[i]) < 0)
continue;
if (stat (path, &st) < 0)
+ ok = 0;
+
+ else if (sts[j].st_dev != st.st_dev ||
+ sts[j].st_ino != st.st_ino)
{
- free (path);
- continue;
- }
- free (path);
- if (sts[j].st_dev != st.st_dev || sts[j].st_ino != st.st_ino)
+ /* maybe the binary has been modified and std[j].st_ino
+ * is not reliable anymore. We need to compare paths.
+ */
+ char linkbuf[PATH_MAX];
+
+ if (readlink(path, linkbuf, sizeof(linkbuf)) <= 0 ||
+ strcmp(namelist[j], linkbuf))
+ ok = 0;
+ }
+
+ free(path);
+ if (!ok)
continue;
}
} /* non-regex */