Fix segfault in pkg version against the ports tree
PR: 224023 Reported by: jrm, kib, Trond.Endrestol@ximalas.info Tested by: jrm (an early version of the patch)
This commit is contained in:
parent
bcf265d0e1
commit
bfd7582edd
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=455589
@ -2,6 +2,7 @@
|
||||
|
||||
PORTNAME= pkg
|
||||
DISTVERSION= 1.10.3
|
||||
PORTREVISION= 1
|
||||
_PKG_VERSION= ${DISTVERSION}
|
||||
CATEGORIES= ports-mgmt
|
||||
MASTER_SITES= \
|
||||
|
28
ports-mgmt/pkg/files/patch-src_version.c
Normal file
28
ports-mgmt/pkg/files/patch-src_version.c
Normal file
@ -0,0 +1,28 @@
|
||||
diff --git src/version.c src/version.c
|
||||
index d265776b..92c18060 100644
|
||||
--- src/version.c
|
||||
+++ src/version.c
|
||||
@@ -601,6 +601,8 @@ exec_buf(UT_string *res, char **argv) {
|
||||
if (errno != EINTR)
|
||||
return (-1);
|
||||
}
|
||||
+ if (WEXITSTATUS(pstat) != 0)
|
||||
+ return (-1);
|
||||
|
||||
return (utstring_len(res));
|
||||
}
|
||||
@@ -716,11 +718,13 @@ port_version(UT_string *cmd, const char *portsdir, const char *origin,
|
||||
argv[3] = "flavors-package-names";
|
||||
argv[4] = NULL;
|
||||
|
||||
- if (exec_buf(cmd, argv) != 0) {
|
||||
+ if (exec_buf(cmd, argv) > 0) {
|
||||
output = utstring_body(cmd);
|
||||
while ((walk = strsep(&output, "\n")) != NULL) {
|
||||
name = walk;
|
||||
walk = strrchr(walk, '-');
|
||||
+ if (walk == NULL)
|
||||
+ continue;
|
||||
walk[0] = '\0';
|
||||
walk++;
|
||||
if (strcmp(name, pkgname) == 0) {
|
Loading…
Reference in New Issue
Block a user