diff options
author | mcf <mcf@pkgsrc.org> | 2020-10-06 00:19:05 +0000 |
---|---|---|
committer | mcf <mcf@pkgsrc.org> | 2020-10-06 00:19:05 +0000 |
commit | bc8bd962121ad30336836819c98503d340463f18 (patch) | |
tree | a3bac7576b750565d164647a820878b4188ccddd /sysutils | |
parent | 6df65bb4f392d7bdd6f8c4af8748d36a3260ae69 (diff) | |
download | pkgsrc-bc8bd962121ad30336836819c98503d340463f18.tar.gz |
psmisc: fix sscanf usage bug under musl libc
C99 says that the %15c conversion specifier matches *exactly* 15
characters, so if the process name is shorter than 15 characters,
it is not matched and 0 is returned. Some implementations (such as
glibc) return a match, even with fewer characters than the field
width, but this cannot be assumed.
Instead, use %15[^)], as in upstream commit [0], which matches a
non-empty sequence of characters other than ')'.
[0] https://gitlab.com/psmisc/psmisc/-/commit/ca2b176889729a7347bd95b832b9a5bb39fec229
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/psmisc/Makefile | 4 | ||||
-rw-r--r-- | sysutils/psmisc/distinfo | 4 | ||||
-rw-r--r-- | sysutils/psmisc/patches/patch-af | 22 |
3 files changed, 22 insertions, 8 deletions
diff --git a/sysutils/psmisc/Makefile b/sysutils/psmisc/Makefile index 37e7794e3df..c87aefe16cd 100644 --- a/sysutils/psmisc/Makefile +++ b/sysutils/psmisc/Makefile @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.32 2020/03/20 11:58:22 nia Exp $ +# $NetBSD: Makefile,v 1.33 2020/10/06 00:19:05 mcf Exp $ DISTNAME= psmisc-20.1 CATEGORIES= sysutils -PKGREVISION= 3 +PKGREVISION= 4 MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=psmisc/} MAINTAINER= pkgsrc-users@NetBSD.org diff --git a/sysutils/psmisc/distinfo b/sysutils/psmisc/distinfo index 04b7c82353e..5c60ee9e637 100644 --- a/sysutils/psmisc/distinfo +++ b/sysutils/psmisc/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.8 2015/11/04 01:32:26 agc Exp $ +$NetBSD: distinfo,v 1.9 2020/10/06 00:19:05 mcf Exp $ SHA1 (psmisc-20.1.tar.gz) = e969a2f539b181c372b0f82bbbd430c4d57d5d6b RMD160 (psmisc-20.1.tar.gz) = 48698ad9f431c881bcb42394f5c912ef91b84d2b @@ -8,5 +8,5 @@ SHA1 (patch-ab) = 74134f6cd2ea0270fdbaff8c0acb9e40767cc5cb SHA1 (patch-ac) = 9f9a7c7c5155345a1045aee70a2dd65a25ec7219 SHA1 (patch-ad) = 6e2886ca59160d161d334e276675f187f138db7c SHA1 (patch-ae) = 484305118582c575f8c4827783aa3d5f57b25b5d -SHA1 (patch-af) = c89f887f572cb7bf22ff05fc6b76eca7fcb34337 +SHA1 (patch-af) = ecba31c5e44291e695eb4b9ea19b9a70cdbd3f67 SHA1 (patch-ag) = a03a4a0c0dbf065e2b2785cee8f23579a11ae13f diff --git a/sysutils/psmisc/patches/patch-af b/sysutils/psmisc/patches/patch-af index f5c785b9893..b87aeaa3028 100644 --- a/sysutils/psmisc/patches/patch-af +++ b/sysutils/psmisc/patches/patch-af @@ -1,7 +1,10 @@ -$NetBSD: patch-af,v 1.6 2014/09/23 22:18:21 jperkin Exp $ +$NetBSD: patch-af,v 1.7 2020/10/06 00:19:05 mcf Exp $ Need limits.h for PATH_MAX +Fix sscanf usage bug on musl libc and uclibc (upstream commit +https://gitlab.com/psmisc/psmisc/-/commit/ca2b176889729a7347bd95b832b9a5bb39fec229) + --- src/pstree.c.orig 2000-12-18 05:59:23.000000000 +0000 +++ src/pstree.c @@ -15,19 +15,22 @@ @@ -65,7 +68,7 @@ Need limits.h for PATH_MAX if ((file = fopen (path, "r")) != NULL) { empty = 0; -@@ -513,6 +519,10 @@ read_proc (void) +@@ -513,16 +519,19 @@ read_proc (void) perror (path); exit (1); } @@ -76,7 +79,18 @@ Need limits.h for PATH_MAX fread(readbuf, BUFSIZ, 1, file) ; if (ferror(file) == 0) { -@@ -532,11 +542,12 @@ read_proc (void) + memset(comm, '\0', COMM_LEN+1); + tmpptr = strrchr(readbuf, ')'); /* find last ) */ +- *tmpptr = '\0'; + /* We now have readbuf with pid and cmd, and tmpptr+2 + * with the rest */ + /*printf("readbuf: %s\n", readbuf);*/ +- if (sscanf(readbuf, "%*d (%15c", comm) == 1) ++ if (sscanf(readbuf, "%*d (%15[^)]", comm) == 1) + { + /*printf("tmpptr: %s\n", tmpptr+2);*/ + if (sscanf(tmpptr+2, "%*c %d", &ppid) == 1) +@@ -532,11 +541,12 @@ read_proc (void) (file, "%d (%s) %c %d", &dummy, comm, (char *) &dummy, &ppid) == 4) */ @@ -90,7 +104,7 @@ Need limits.h for PATH_MAX if ((fd = open (path, O_RDONLY)) < 0) { perror (path); -@@ -641,7 +652,11 @@ main (int argc, char **argv) +@@ -641,7 +651,11 @@ main (int argc, char **argv) switch (c) { case 'a': |