This commit is contained in:
openeuler-basic 2019-12-31 23:06:09 +08:00
parent 43ad3bda3f
commit 8b1a691179
10 changed files with 418 additions and 0 deletions

View File

@ -0,0 +1,39 @@
From 14fbe53b773ef0baed3f3e13fa02c246a98e29b2 Mon Sep 17 00:00:00 2001
From: openEuler Buildteam <buildteam@openeuler.org>
Date: Tue, 31 Dec 2019 22:27:16 +0800
Subject: [PATCH] change pkgconfigdir from lib to lib64
---
Makefile.am | 2 +-
Makefile.in | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index d7aec9e..50ad731 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 = $(prefix)/lib64/pkgconfig
pkgconfig_DATA = popt.pc
if HAVE_LD_VERSION_SCRIPT
diff --git a/Makefile.in b/Makefile.in
index 2e6890d..2620636 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -370,7 +370,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@ \
$(am__append_1)
-pkgconfigdir = $(prefix)/lib/pkgconfig
+pkgconfigdir = $(prefix)/lib64/pkgconfig
pkgconfig_DATA = popt.pc
man_MANS = popt.3
BUILT_SOURCES = popt.pc # popt.lcd
--
1.8.3.1

View File

@ -0,0 +1,26 @@
From 03fa3b9361fb08e7575021b4830f3e220c7206e0 Mon Sep 17 00:00:00 2001
From: devzero2000 <devzero2000>
Date: Fri, 16 Aug 2013 08:13:29 +0000
Subject: [PATCH 141/157] fix coverity CID 1057440: Unused pointer value
(UNUSED_VALUE)
---
popt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/popt.c b/popt.c
index adb70b5..5dc6812 100644
--- a/popt.c
+++ b/popt.c
@@ -1692,7 +1692,7 @@ assert(s); /* XXX can't happen */
if (opt->longName) {
if (!F_ISSET(opt, ONEDASH))
*s++ = '-';
- s = stpcpy(s, opt->longName);
+ (void)stpcpy(s, opt->longName);
} else {
*s++ = opt->shortName;
*s = '\0';
--
2.19.1

View File

@ -0,0 +1,39 @@
From ffa18b1e6a649164788b7c21720293c16d374e92 Mon Sep 17 00:00:00 2001
From: jbj <jbj>
Date: Mon, 24 Jun 2013 21:14:37 +0000
Subject: [PATCH 123/157] - fix: handle newly added asset(...) call like
elsewhere.
---
poptconfig.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/poptconfig.c b/poptconfig.c
index 0a9a50d..fad03c5 100644
--- a/poptconfig.c
+++ b/poptconfig.c
@@ -74,6 +74,12 @@ glob_pattern_p (const char * pattern, int quote)
}
#endif /* !defined(__GLIBC__) */
+#if defined(HAVE_ASSERT_H)
+#include <assert.h>
+#else
+#define assert(_x)
+#endif
+
/*@unchecked@*/
static int poptGlobFlags = 0;
@@ -332,7 +338,7 @@ static int poptConfigLine(poptContext con, char * line)
longName++;
else
longName = fn;
- if (longName == NULL) /* XXX can't happen. */
+assert(longName != NULL); /* XXX can't happen. */
goto exit;
/* Single character basenames are treated as short options. */
if (longName[1] != '\0')
--
2.19.1

View File

@ -0,0 +1,26 @@
From 9c977f94d59f55d86e6f0cfbc3cd9401861b75b0 Mon Sep 17 00:00:00 2001
From: jbj <jbj>
Date: Mon, 9 Aug 2010 17:31:45 +0000
Subject: [PATCH 051/157] - fix: obscure iconv mis-call error path could lead
to strdup(NULL) (coverity).
---
poptint.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/poptint.c b/poptint.c
index 5e09fa4..67f0051 100644
--- a/poptint.c
+++ b/poptint.c
@@ -145,7 +145,7 @@ assert(dstr); /* XXX can't happen */
}
(void) iconv_close(cd);
*pout = '\0';
- ostr = xstrdup(dstr);
+ ostr = xstrdup(dstr ? dstr : istr);
free(dstr);
} else
ostr = xstrdup(istr);
--
2.19.1

View File

@ -0,0 +1,25 @@
From 2529204650351a6fb521aab72565a08c1665d8e2 Mon Sep 17 00:00:00 2001
From: jbj <jbj>
Date: Wed, 3 Jul 2013 19:44:37 +0000
Subject: [PATCH 135/157] - fix: permit reading aliases, remove left over "goto
exit" replacing by assert.
---
poptconfig.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/poptconfig.c b/poptconfig.c
index fad03c5..b8e1da6 100644
--- a/poptconfig.c
+++ b/poptconfig.c
@@ -339,7 +339,6 @@ static int poptConfigLine(poptContext con, char * line)
else
longName = fn;
assert(longName != NULL); /* XXX can't happen. */
- goto exit;
/* Single character basenames are treated as short options. */
if (longName[1] != '\0')
item->option.longName = longName;
--
2.19.1

71
popt-1.16-execfail.patch Normal file
View File

@ -0,0 +1,71 @@
Patch by Panu Matilainen <pmatilai@redhat.com> for popt <= 1.16 which kludges
poptBadOption() to return something semi-meaningful on exec alias fail:
- poptBadOption() is totally unaware of exec alias failures, and will return
either the first argument or last option, giving wonderfully misleading error
messages (#697435, #710267).
- Remember execvp() first argument on failure and return that from
poptBadOption() if present to give the user a reasonable clue what exactly
went wrong.
This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0264.html
--- 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;
+ con->execFail = NULL;
con->finalArgvAlloced = argc * 2;
con->finalArgv = calloc( (size_t)con->finalArgvAlloced, sizeof(*con->finalArgv) );
con->execAbsolute = 1;
@@ -236,6 +237,7 @@
con->nextLeftover = 0;
con->restLeftover = 0;
con->doExec = NULL;
+ con->execFail = _free(con->execFail);
if (con->finalArgv != NULL)
for (i = 0; i < con->finalArgvCount; i++) {
@@ -564,6 +566,7 @@
/*@-nullstate@*/
rc = execvp(argv[0], (char *const *)argv);
/*@=nullstate@*/
+ con->execFail = xstrdup(argv[0]);
exit:
if (argv) {
@@ -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) {
+ badOpt = con->execFail;
+ } else {
+ os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
+ badOpt = os->argv[os->next - 1];
+ }
+ }
- return (os != NULL && os->argv != NULL ? os->argv[os->next - 1] : NULL);
+ return badOpt;
}
const char * poptStrerror(const int error)
--- 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;
+ char * execFail;
/*@only@*/ /*@null@*/
poptArgv finalArgv;
int finalArgvCount;

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

@ -0,0 +1,79 @@
From 6fcb24d785a2c2d626bac6999aee6b3ab368be15 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 28 Jul 2017 16:11:40 -0400
Subject: [PATCH] Don't leak the last argument expanded by expandNextArg()
While using POPT_ARG_ARGV, I noticed this in valgrind's leak checker:
==1738== HEAP SUMMARY:
==1738== in use at exit: 8 bytes in 1 blocks
==1738== total heap usage: 94 allocs, 93 frees, 42,319 bytes allocated
==1738==
==1738== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1
==1738== at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
==1738== by 0x4E3DF47: expandNextArg (popt.c:699)
==1738== by 0x4E3F681: poptGetNextOpt (popt.c:1501)
==1738== by 0x401F72: main (bingrep.c:433)
==1738==
==1738== LEAK SUMMARY:
==1738== definitely lost: 8 bytes in 1 blocks
==1738== indirectly lost: 0 bytes in 0 blocks
==1738== possibly lost: 0 bytes in 0 blocks
==1738== still reachable: 0 bytes in 0 blocks
==1738== suppressed: 0 bytes in 0 blocks
My command line argument is a 7-byte string, and on first glance, it
appears this is because both expandNextArg() and poptSaveString()
duplicate the string. The copy from poptSaveString() is the consuming
program's responsibility to free, but the intermediate pointer is popt's
responsibility.
Upon further examination, it appears popt normally does free this
string, but it only does it on the next entry to poptGetNextOpt(), and
on cleanOSE() in the case if we're not already at the bottom of
con->OptionStack.
This patch modifies poptResetContext() to ensure we'll always attempt to
free con->os->nextArg regardless of our position in the OptionStack, and
removes the duplicate free of con->os->argb in poptFreeContext(), as
it's called unconditionally by the poptResetContext() call on the
previous line.
This ensures that if poptGetNextOpt() isn't re-intered, poptFreeContext()
will free the memory that was allocated. Now valgrind tells me:
==31734== HEAP SUMMARY:
==31734== in use at exit: 0 bytes in 0 blocks
==31734== total heap usage: 94 allocs, 94 frees, 42,319 bytes allocated
==31734==
==31734== All heap blocks were freed -- no leaks are possible
Signed-off-by: Peter Jones <pjones@redhat.com>
---
popt.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/popt.c b/popt.c
index 1a53f40..72fbf5c 100644
--- a/popt.c
+++ b/popt.c
@@ -230,7 +230,7 @@ void poptResetContext(poptContext con)
con->os->argb = PBM_FREE(con->os->argb);
con->os->currAlias = NULL;
con->os->nextCharArg = NULL;
- con->os->nextArg = NULL;
+ con->os->nextArg = _free(con->os->nextArg);
con->os->next = 1; /* skip argv[0] */
con->numLeftovers = 0;
@@ -1617,7 +1617,6 @@ poptContext poptFreeContext(poptContext con)
{
if (con == NULL) return con;
poptResetContext(con);
- con->os->argb = _free(con->os->argb);
con->aliases = poptFreeItems(con->aliases, con->numAliases);
con->numAliases = 0;
--
2.13.3

BIN
popt-1.16.tar.gz Normal file

Binary file not shown.

89
popt.spec Normal file
View File

@ -0,0 +1,89 @@
Name: popt
Version: 1.16
Release: 17
Summary: C library for parsing command line parameters
License: MIT
URL: http://www.rpm5.org
Source0: http://www.rpm5.org/files/%{name}/%{name}-%{version}.tar.gz
Patch0: change-pkgconfigdir-from-lib-to-lib64.patch
Patch1: popt-1.16-execfail.patch
Patch2: popt-1.16-nextarg-memleak.patch
Patch3: popt-1.16-glob-error.patch
Patch9000: fix-obscure-iconv-mis-call-error-path-could-lead-to-.patch
Patch9001: fix-handle-newly-added-asset-.-call-like-elsewhere.patch
Patch9002: fix-permit-reading-aliases-remove-left-over-goto-exi.patch
Patch9003: fix-coverity-CID-1057440-Unused-pointer-value-UNUSED.patch
BuildRequires: gcc git gettext
%description
The popt library exists essentially for parsing command line options. Some
specific advantages of popt are no global variables (allowing multiple passes
in parsing argv), parsing an arbitrary array of argv-style elements (allowing
parsing of command-line-strings from any source), a standard method of option
aliasing, ability to exec external option filters, and automatic generation
of help and usage messages.
%package devel
Summary: Development files for %{name}
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig
Provides: %{name}-static = %{version}-%{release}
Obsoletes: %{name}-static < %{version}-%{release}
%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
%package help
Summary: Doc files for %{name}
Buildarch: noarch
%description help
The %{name}-help package contains doc files for %{name}.
%prep
%autosetup -n %{name}-%{version} -p1
%build
%configure
%make_build
%install
%make_install
rm -f %{buildroot}/%{_libdir}/libpopt.la
mkdir -p %{buildroot}/%{_sysconfdir}/popt.d
%find_lang %{name}
%check
make check
%pre
%preun
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files -f %{name}.lang
%license COPYING
%{_sysconfdir}/%{name}.d
%{_libdir}/lib%{name}.so*
%files devel
%{_includedir}/%{name}.h
%{_libdir}/pkgconfig/%{name}.pc
%{_libdir}/lib%{name}.a
%files help
%doc CHANGES README
%{_mandir}/man3/%{name}.3.gz
%changelog
* Tue Dec 31 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.16-17
- Strenthen spec
* Fri Aug 30 2019 luhuaxin <luhuaxin@huawei.com> - 1.16-16
- Package init