Added upstream patch to handle glob(3) error returns (#1051685)

This commit is contained in:
Robert Scheck 2017-10-12 23:54:35 +02:00
parent 4f57ac2fe2
commit ec170d0e68
9 changed files with 84 additions and 122 deletions

2
.gitignore vendored
View File

@ -1,5 +1,3 @@
/popt-*.tar
/popt-*.tar.*
/*/
/.build*.log
/*.rpm

View File

@ -1,9 +1,3 @@
From 61cc5004fb8e14464ae0afcffc6e2ee852b45a41 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 28 Jul 2017 15:17:22 -0400
Subject: [PATCH 2/4] kludge poptBadOption() to return value on exec alias
failure
Patch by Panu Matilainen <pmatilai@redhat.com> for popt <= 1.16 which kludges
poptBadOption() to return something semi-meaningful on exec alias fail:
@ -15,16 +9,10 @@ poptBadOption() to return something semi-meaningful on exec alias fail:
went wrong.
This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0264.html
---
popt.c | 19 +++++++++++++++----
poptint.h | 1 +
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/popt.c b/popt.c
index a1c38a5..1a53f40 100644
--- a/popt.c
+++ b/popt.c
@@ -192,6 +192,7 @@ poptContext poptGetContext(const char * name, int argc, const char ** argv,
--- popt-1.16/popt.c 2010-01-19 01:39:10.000000000 +0100
+++ popt-1.16/popt.c.execfail 2013-11-24 15:50:06.000000000 +0100
@@ -192,6 +192,7 @@
con->flags = flags;
con->execs = NULL;
con->numExecs = 0;
@ -32,7 +20,7 @@ index a1c38a5..1a53f40 100644
con->finalArgvAlloced = argc * 2;
con->finalArgv = calloc( (size_t)con->finalArgvAlloced, sizeof(*con->finalArgv) );
con->execAbsolute = 1;
@@ -236,6 +237,7 @@ void poptResetContext(poptContext con)
@@ -236,6 +237,7 @@
con->nextLeftover = 0;
con->restLeftover = 0;
con->doExec = NULL;
@ -40,7 +28,7 @@ index a1c38a5..1a53f40 100644
if (con->finalArgv != NULL)
for (i = 0; i < con->finalArgvCount; i++) {
@@ -564,6 +566,7 @@ if (_popt_debug)
@@ -564,6 +566,7 @@
/*@-nullstate@*/
rc = execvp(argv[0], (char *const *)argv);
/*@=nullstate@*/
@ -48,12 +36,14 @@ index a1c38a5..1a53f40 100644
exit:
if (argv) {
@@ -1697,11 +1700,19 @@ int poptAddItem(poptContext con, poptItem newItem, int flags)
@@ -1697,11 +1700,19 @@
const char * poptBadOption(poptContext con, unsigned int flags)
{
struct optionStackEntry * os = NULL;
+ const char *badOpt = NULL;
+
- if (con != NULL)
- os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
+ if (con != NULL) {
+ /* Stupid hack to return something semi-meaningful from exec failure */
+ if (con->execFail) {
@ -64,19 +54,14 @@ index a1c38a5..1a53f40 100644
+ }
+ }
- if (con != NULL)
- os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
-
- return (os != NULL && os->argv != NULL ? os->argv[os->next - 1] : NULL);
+ return badOpt;
}
const char * poptStrerror(const int error)
diff --git a/poptint.h b/poptint.h
index 80cbaca..0fcb26e 100644
--- a/poptint.h
+++ b/poptint.h
@@ -132,6 +132,7 @@ struct poptContext_s {
--- popt-1.16/poptint.h 2010-01-19 01:39:10.000000000 +0100
+++ popt-1.16/poptint.h.execfail 2013-11-24 15:50:38.000000000 +0100
@@ -132,6 +132,7 @@
/*@owned@*/ /*@null@*/
poptItem execs;
int numExecs;
@ -84,6 +69,3 @@ index 80cbaca..0fcb26e 100644
/*@only@*/ /*@null@*/
poptArgv finalArgv;
int finalArgvCount;
--
2.13.3

View File

@ -0,0 +1,24 @@
Backport of upstream http://rpm5.org/cvs/chngview?cn=19258
--- popt-1.16/poptconfig.c 2009-05-20 15:18:07.000000000 +0200
+++ popt-1.16/poptconfig.c.glob-error 2017-10-12 23:33:28.868435647 +0200
@@ -108,7 +108,7 @@
if (glob_pattern_p(pat, 0)) {
glob_t _g, *pglob = &_g;
- if (!glob(pat, poptGlobFlags, poptGlob_error, pglob)) {
+ if (!(rc = glob(pat, poptGlobFlags, poptGlob_error, pglob))) {
if (acp) {
*acp = (int) pglob->gl_pathc;
pglob->gl_pathc = 0;
@@ -122,6 +122,10 @@
/*@-nullstate@*/
globfree(pglob);
/*@=nullstate@*/
+ } else if (rc == GLOB_NOMATCH) {
+ *avp = NULL;
+ *acp = 0;
+ rc = 0;
} else
rc = POPT_ERROR_ERRNO;
} else

View File

@ -1,11 +1,3 @@
From 1d86877a865338e554aa2480f021da517a86954f Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 28 Jul 2017 15:18:46 -0400
Subject: [PATCH 4/4] Make --help and --usage translatable.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Patch initially by Miloslav Trmač <mitr@redhat.com> and revised by Akira Tagoh
<tagoh@redhat.com> for popt <= 1.16 which fixes the problem that help messages
for --help and --usage seem not translatable. There already was some i18n support
@ -14,15 +6,10 @@ for autohelp in popt.c, but not in popthelp.c, where it actually matters.
See https://bugzilla.redhat.com/show_bug.cgi?id=734434 for further details, please.
This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0287.html
---
popthelp.c | 39 ++++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 13 deletions(-)
diff --git a/popthelp.c b/popthelp.c
index 4859980..008fb2b 100644
--- a/popthelp.c
+++ b/popthelp.c
@@ -89,7 +89,7 @@ static struct poptOption poptHelpOptions2[] = {
--- popt-1.16/popthelp.c 2009-08-28 09:06:33.000000000 +0900
+++ popt-1.16/popthelp.c.help 2014-01-08 12:04:00.888260244 +0900
@@ -89,7 +89,7 @@ static struct poptOption poptHelpOptions
{ "defaults", '\0', POPT_ARG_NONE, &show_option_defaults, 0,
N_("Display option defaults in message"), NULL },
#endif
@ -31,7 +18,7 @@ index 4859980..008fb2b 100644
POPT_TABLEEND
} ;
@@ -527,8 +527,11 @@ static size_t maxArgWidth(const struct poptOption * opt,
@@ -527,8 +527,11 @@ static size_t maxArgWidth(const struct p
if (opt != NULL)
while (opt->longName || opt->shortName || opt->arg) {
if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) {
@ -45,7 +32,7 @@ index 4859980..008fb2b 100644
if (len > max) max = len;
} else if (!F_ISSET(opt, DOC_HIDDEN)) {
len = sizeof(" ")-1;
@@ -619,19 +622,22 @@ static void singleTableHelp(poptContext con, FILE * fp,
@@ -619,19 +622,22 @@ static void singleTableHelp(poptContext
if (table != NULL)
for (opt = table; opt->longName || opt->shortName || opt->arg; opt++) {
@ -71,7 +58,7 @@ index 4859980..008fb2b 100644
}
}
@@ -808,22 +814,25 @@ static size_t singleTableUsage(poptContext con, FILE * fp, columns_t columns,
@@ -808,22 +814,25 @@ static size_t singleTableUsage(poptConte
translation_domain = (const char *)opt->arg;
} else
if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) {
@ -101,7 +88,7 @@ index 4859980..008fb2b 100644
translation_domain, done);
} else
if ((opt->longName || opt->shortName) && !F_ISSET(opt, DOC_HIDDEN)) {
@@ -864,9 +873,13 @@ static size_t showShortOptions(const struct poptOption * opt, FILE * fp,
@@ -864,9 +873,13 @@ static size_t showShortOptions(const str
if (!strchr(s, opt->shortName) && isprint((int)opt->shortName)
&& opt->shortName != ' ')
s[strlen(s)] = opt->shortName;
@ -118,6 +105,3 @@ index 4859980..008fb2b 100644
}
/* On return to top level, print the short options, return print length. */
--
2.13.3

View File

@ -1,8 +1,3 @@
From abc7cc36f265e2fff199eca94e8cbf1cd0a28ab5 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 28 Jul 2017 15:18:15 -0400
Subject: [PATCH 3/4] Fix some spelling mistakes in the man page.
Patch by John Bradshaw <john@johnbradshaw.org> for popt <= 1.16 which fixes some
spelling mistakes in popt man page.
@ -12,15 +7,10 @@ This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0263.h
Upstream already corrected some issues with http://rpm5.org/cvs/chngview?cn=16879
and solved the last ones with http://rpm5.org/cvs/chngview?cn=17375 now. Thus popt
1.17 should make this patch completely obsolete.
---
popt.3 | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/popt.3 b/popt.3
index 5d5a556..ca64a92 100644
--- a/popt.3
+++ b/popt.3
@@ -200,7 +200,7 @@ arguments.
--- popt-1.16/popt.3 2009-07-25 20:52:36.000000000 +0200
+++ popt-1.16/popt.3.man-page 2013-11-24 15:59:58.000000000 +0100
@@ -200,7 +200,7 @@
.RB "This macro includes another option table (via " POPT_ARG_INCLUDE_TABLE
; see below) in the main one which provides the table entries for these
.RB "arguments. When " --usage " or " --help " are passed to programs which
@ -29,7 +19,7 @@ index 5d5a556..ca64a92 100644
stderr as soon as it finds the option, and exits the program with a
return code of 0. If you want to use popt's automatic help generation in
a different way, you need to explicitly add the option entries to your programs
@@ -210,7 +210,7 @@ If the \fIargInfo\fR value is bitwise or'd with \fBPOPT_ARGFLAG_DOC_HIDDEN\fR,
@@ -210,7 +210,7 @@
the argument will not be shown in help output.
.sp
If the \fIargInfo\fR value is bitwise or'd with \fBPOPT_ARGFLAG_SHOW_DEFAULT\fR,
@ -38,7 +28,7 @@ index 5d5a556..ca64a92 100644
.sp
The final structure in the table should have all the pointer values set
.RB "to " NULL " and all the arithmetic values set to 0, marking the "
@@ -233,7 +233,7 @@ automatic help generation is being used, the \fIdescrip\fR field should
@@ -233,7 +233,7 @@
contain a overall description of the option table being included.
.sp
The other special option table entry type tells popt to call a function (a
@ -47,7 +37,7 @@ index 5d5a556..ca64a92 100644
when included option tables are being used, as the program which provides
the top-level option table doesn't need to be aware of the other options
which are provided by the included table. When a callback is set for
@@ -473,7 +473,7 @@ A parsed string has a quotation mismatch (such as a single quotation
@@ -473,7 +473,7 @@
.TP
.B POPT_ERROR_BADNUMBER
A conversion from a string to a number (int or long) failed due
@ -56,7 +46,7 @@ index 5d5a556..ca64a92 100644
.BR poptGetNextOpt() " is processing an argument of type "
.BR POPT_ARG_INT ", " POPT_ARG_SHORT ", " POPT_ARG_LONG ", " POPT_ARG_LONGLONG ", "
.RB POPT_ARG_FLOAT ", or " POPT_ARG_DOUBLE "."
@@ -517,7 +517,7 @@ These two functions make popt error handling trivial for most
@@ -517,7 +517,7 @@
applications. When an error is detected from most of the functions,
an error message is printed along with the error string from
.BR poptStrerror() ". When an error occurs during argument parsing, "
@ -65,7 +55,7 @@ index 5d5a556..ca64a92 100644
.sp
.nf
fprintf(stderr, "%s: %s\\n",
@@ -608,7 +608,7 @@ Although popt is usually used for parsing arguments already divided into
@@ -608,7 +608,7 @@
.RI "an " argv "-style array, some programs need to parse strings that "
are formatted identically to command lines. To facilitate this, popt
provides a function that parses a string into an array of strings,
@ -74,6 +64,3 @@ index 5d5a556..ca64a92 100644
.sp
.nf
.B "#include <popt.h>"
--
2.13.3

View File

@ -1,8 +1,3 @@
From cac87554c89d55dd7c082ad4b234314e72d73a22 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 28 Jul 2017 15:16:17 -0400
Subject: [PATCH 1/4] Update pkgconfig directory
Patch by Robert Scheck <robert@fedoraproject.org> for popt <= 1.16 which changes
$(pkgconfigdir) on 64 bit systems from /usr/lib/pkgconfig to /usr/lib64/pkgconfig.
Using $(libdir)/pkgconfig rather $(prefix)/lib/pkgconfig seems to be common when
@ -11,29 +6,10 @@ searching on the Internet. This patch however is not really compliant with Fedor
--with-pkgconfigdir or similar should be implemented.
This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0265.html
---
Makefile.am | 2 +-
Makefile.in | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index d7aec9e..8cc6220 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -47,7 +47,7 @@ usrlib_LTLIBRARIES = libpopt.la
libpopt_la_SOURCES = popt.c poptparse.c poptconfig.c popthelp.c poptint.c
libpopt_la_LDFLAGS = -no-undefined @LTLIBINTL@ @LTLIBICONV@
-pkgconfigdir = $(prefix)/lib/pkgconfig
+pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = popt.pc
if HAVE_LD_VERSION_SCRIPT
diff --git a/Makefile.in b/Makefile.in
index 2e6890d..c331e20 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -370,7 +370,7 @@ usrlib_LTLIBRARIES = libpopt.la
--- popt-1.16/Makefile.in 2010-05-04 22:55:59.000000000 +0200
+++ popt-1.16/Makefile.in.pkgconfig 2013-11-24 15:06:43.000000000 +0100
@@ -370,7 +370,7 @@
libpopt_la_SOURCES = popt.c poptparse.c poptconfig.c popthelp.c poptint.c
libpopt_la_LDFLAGS = -no-undefined @LTLIBINTL@ @LTLIBICONV@ \
$(am__append_1)
@ -42,6 +18,14 @@ index 2e6890d..c331e20 100644
pkgconfig_DATA = popt.pc
man_MANS = popt.3
BUILT_SOURCES = popt.pc # popt.lcd
--
2.13.3
--- popt-1.16/Makefile.am 2010-05-04 22:55:54.000000000 +0200
+++ popt-1.16/Makefile.am.pkgconfig 2013-11-24 15:02:21.000000000 +0100
@@ -47,7 +47,7 @@
libpopt_la_SOURCES = popt.c poptparse.c poptconfig.c popthelp.c poptint.c
libpopt_la_LDFLAGS = -no-undefined @LTLIBINTL@ @LTLIBICONV@
-pkgconfigdir = $(prefix)/lib/pkgconfig
+pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = popt.pc
if HAVE_LD_VERSION_SCRIPT

View File

@ -1,18 +1,18 @@
Summary: C library for parsing command line parameters
Name: popt
Version: 1.16
Release: 11%{?dist}
Release: 12%{?dist}
License: MIT
Group: System Environment/Libraries
URL: http://www.rpm5.org/
Source: http://www.rpm5.org/files/%{name}/%{name}-%{version}.tar.gz
Patch0001: 0001-Update-pkgconfig-directory.patch
Patch0002: 0002-kludge-poptBadOption-to-return-value-on-exec-alias-f.patch
Patch0003: 0003-Fix-some-spelling-mistakes-in-the-man-page.patch
Patch0004: 0004-Make-help-and-usage-translatable.patch
Patch0005: 0005-Don-t-leak-the-last-argument-expanded-by-expandNextA.patch
BuildRequires: gettext git
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Patch0: popt-1.16-pkgconfig.patch
Patch1: popt-1.16-execfail.patch
Patch2: popt-1.16-man-page.patch
Patch3: popt-1.16-help.patch
Patch4: popt-1.16-nextarg-memleak.patch
Patch5: popt-1.16-glob-error.patch
BuildRequires: gcc gettext
%description
Popt is a C library for parsing command line parameters. Popt was
@ -44,7 +44,13 @@ The popt-static package includes static libraries of the popt library.
Install it if you need to link statically with libpopt.
%prep
%autosetup -S git
%setup -q
%patch0 -p1 -b .pkgconfig
%patch1 -p1 -b .execfail
%patch2 -p1 -b .man-page
%patch3 -p1 -b .help
%patch4 -p1 -b .nextarg-memleak
%patch5 -p1 -b .glob-error
%build
%if 0%{?fedora} < 17 && 0%{?rhel} < 7
@ -76,9 +82,6 @@ mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/popt.d
%find_lang %{name}
%clean
rm -rf $RPM_BUILD_ROOT
%check
make check
@ -87,7 +90,6 @@ make check
%postun -p /sbin/ldconfig
%files -f %{name}.lang
%defattr(-,root,root,-)
%license COPYING
%doc CHANGES
%{_sysconfdir}/popt.d
@ -98,7 +100,6 @@ make check
%endif
%files devel
%defattr(-,root,root,-)
%doc README
%{_libdir}/libpopt.so
%{_libdir}/pkgconfig/%{name}.pc
@ -106,10 +107,12 @@ make check
%{_mandir}/man3/popt.3*
%files static
%defattr(-,root,root,-)
%{_libdir}/libpopt.a
%changelog
* Thu Oct 12 2017 Robert Scheck <robert@fedoraproject.org> 1.16-12
- Added upstream patch to handle glob(3) error returns (#1051685)
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.16-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

View File

@ -1 +1 @@
3743beefa3dd6247a73f8f7a32c14c33 popt-1.16.tar.gz
SHA512 (popt-1.16.tar.gz) = bae2dd4e5d682ef023fdc77ae60c4aad01a3a576d45af9d78d22490c11e410e60edda37ede171920746d4ae0d5de3c060d15cecfd41ba75b727a811be828d694