Compare commits
10 Commits
b1826f6075
...
f1da39f2d9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1da39f2d9 | ||
|
|
12035d81a4 | ||
|
|
034e622740 | ||
|
|
924384baf4 | ||
|
|
000f128a29 | ||
|
|
69e9706467 | ||
|
|
2256d09cc2 | ||
|
|
7f62c46441 | ||
|
|
1c33002d26 | ||
|
|
74d48edf3e |
63
Fix-multiple-typos-in-comments.patch
Normal file
63
Fix-multiple-typos-in-comments.patch
Normal file
@ -0,0 +1,63 @@
|
||||
From 1bd2a0e35478be573cb8848b0f63ef98136a3ad7 Mon Sep 17 00:00:00 2001
|
||||
From: Robert Scheck <robert@fedoraproject.org>
|
||||
Date: Tue, 3 Jan 2023 00:31:31 +0100
|
||||
Subject: [PATCH] Fix multiple typos in comments
|
||||
|
||||
---
|
||||
src/popt.c | 8 ++++----
|
||||
src/system.h | 2 +-
|
||||
2 files changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/popt.c b/src/popt.c
|
||||
index 7a555bb4..4759254f 100644
|
||||
--- a/src/popt.c
|
||||
+++ b/src/popt.c
|
||||
@@ -142,7 +142,7 @@ static void invokeCallbacksOPTION(poptContext con,
|
||||
{ const void *cbData = (cbopt->descrip ? cbopt->descrip : myData);
|
||||
cbarg.cb(con, POPT_CALLBACK_REASON_OPTION,
|
||||
myOpt, con->os->nextArg, cbData);
|
||||
- /* Terminate (unless explcitly continuing). */
|
||||
+ /* Terminate (unless explicitly continuing). */
|
||||
if (!CBF_ISSET(cbopt, CONTINUE))
|
||||
return;
|
||||
}
|
||||
@@ -305,7 +305,7 @@ longOptionStrcmp(const struct poptOption * opt,
|
||||
const char * optLongName = opt->longName;
|
||||
int rc;
|
||||
|
||||
- if (optLongName == NULL || longName == NULL) /* XXX can't heppen */
|
||||
+ if (optLongName == NULL || longName == NULL) /* XXX can't happen */
|
||||
return 0;
|
||||
|
||||
if (F_ISSET(opt, TOGGLE)) {
|
||||
@@ -576,7 +576,7 @@ findOption(const struct poptOption * opt,
|
||||
opt2 = findOption(arg.opt, longName, longNameLen, shortName, callback,
|
||||
callbackData, argInfo);
|
||||
if (opt2 == NULL) continue;
|
||||
- /* Sub-table data will be inheirited if no data yet. */
|
||||
+ /* Sub-table data will be inherited if no data yet. */
|
||||
if (callback && *callback
|
||||
&& callbackData && *callbackData == NULL)
|
||||
*callbackData = opt->descrip;
|
||||
@@ -1060,7 +1060,7 @@ static unsigned int poptArgInfo(poptContext con, const struct poptOption * opt)
|
||||
/* XXX almost good enough but consider --[no]nofoo corner cases. */
|
||||
if (longName[0] != opt->longName[0] || longName[1] != opt->longName[1])
|
||||
{
|
||||
- if (!LF_ISSET(XOR)) { /* XXX dont toggle with XOR */
|
||||
+ if (!LF_ISSET(XOR)) { /* XXX don't toggle with XOR */
|
||||
/* Toggle POPT_BIT_SET <=> POPT_BIT_CLR. */
|
||||
if (LF_ISSET(LOGICALOPS))
|
||||
argInfo ^= (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND);
|
||||
diff --git a/src/system.h b/src/system.h
|
||||
index 5faeabe7..512d685b 100644
|
||||
--- a/src/system.h
|
||||
+++ b/src/system.h
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
-/* XXX isspace(3) has i18n encoding signednesss issues on Solaris. */
|
||||
+/* XXX isspace(3) has i18n encoding signedness issues on Solaris. */
|
||||
#define _isspaceptr(_chp) isspace((int)(*(unsigned const char *)(_chp)))
|
||||
|
||||
#ifdef HAVE_MCHECK_H
|
||||
32
Fix-poptCallbackType-documentation.patch
Normal file
32
Fix-poptCallbackType-documentation.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 86bb2d971bd86581180a4e2ee2707fb884bed001 Mon Sep 17 00:00:00 2001
|
||||
From: Felipe Gasper <felipe@felipegasper.com>
|
||||
Date: Sat, 29 Oct 2022 21:12:07 -0400
|
||||
Subject: [PATCH] Fix poptCallbackType documentation.
|
||||
|
||||
Issue #87
|
||||
---
|
||||
popt.3 | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/popt.3 b/popt.3
|
||||
index 14b6d569..a490d4bc 100644
|
||||
--- a/popt.3
|
||||
+++ b/popt.3
|
||||
@@ -246,12 +246,15 @@ Option callbacks should match the following prototype:
|
||||
.sp
|
||||
.nf
|
||||
.BI "void poptCallbackType(poptContext con,
|
||||
+.BI " enum poptCallbackReason reason,
|
||||
.BI " const struct poptOption * opt,
|
||||
-.BI " const char * arg, void * data);
|
||||
+.BI " const char * arg, const void * data);
|
||||
.fi
|
||||
.sp
|
||||
The first parameter is the context which is being parsed (see the next
|
||||
-section for information on contexts), \fIopt\fR points to the option
|
||||
+section for information on contexts). \fIreason\fR is
|
||||
+\fBPOPT_CALLBACK_REASON_PRE\fR, \fBPOPT_CALLBACK_REASON_POST\fR, or
|
||||
+\fBPOPT_CALLBACK_REASON_OPTION\fR. \fIopt\fR points to the option
|
||||
which triggered this callback, and \fIarg\fR is the option's argument.
|
||||
If the option does not take an argument, \fIarg\fR is \fBNULL\fR. The
|
||||
final parameter, \fIdata\fR is taken from the \fIdescrip\fR field
|
||||
34
Fix-potential-double-free-in-test3.c.patch
Normal file
34
Fix-potential-double-free-in-test3.c.patch
Normal file
@ -0,0 +1,34 @@
|
||||
From 0983d0a55701c490f21fc741068c7a09c99a4aa9 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Domonkos <mdomonko@redhat.com>
|
||||
Date: Thu, 16 May 2024 12:37:57 +0200
|
||||
Subject: [PATCH] Fix potential double-free in test3.c
|
||||
|
||||
The pointer to newargv passed to poptParseArgvString() may not be
|
||||
assigned to in case of an error, and it still may contain an address to
|
||||
already freed memory from the previous for loop iteration.
|
||||
|
||||
To fix, add a return value check, similar to the one above it for the
|
||||
out pointer.
|
||||
|
||||
Found by a static analyzer.
|
||||
---
|
||||
tests/test3.c | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/test3.c b/tests/test3.c
|
||||
index aa91167a..f1ee7774 100644
|
||||
--- a/tests/test3.c
|
||||
+++ b/tests/test3.c
|
||||
@@ -30,7 +30,11 @@ int main (int argc, char **argv) {
|
||||
|
||||
printf ("single string: '%s'\n", out);
|
||||
|
||||
- poptParseArgvString (out, &newargc, &newargv);
|
||||
+ ret = poptParseArgvString (out, &newargc, &newargv);
|
||||
+ if (ret != 0) {
|
||||
+ printf ("cannot parse %s. ret=%d\n", out, ret);
|
||||
+ continue;
|
||||
+ }
|
||||
|
||||
printf ("popt array: size=%d\n", newargc);
|
||||
for (j = 0; j < newargc; j++)
|
||||
@ -1,38 +0,0 @@
|
||||
From cd32d1c7da8265a06491d72190c649496ae2f489 Mon Sep 17 00:00:00 2001
|
||||
From: Tobias Stoeckmann <tobias@stoeckmann.org>
|
||||
Date: Sun, 16 Aug 2020 20:39:20 +0200
|
||||
Subject: [PATCH] Consider POPT_CONTEXT_KEEP_FIRST during reset.
|
||||
|
||||
If context is created with POPT_CONTEXT_KEEP_FIRST flag, then the
|
||||
first argv entry is parsed as well (argv[0] is normally the program
|
||||
name).
|
||||
|
||||
Calling poptResetContext should reset the context exactly back into
|
||||
the state in wich it was after poptGetContext.
|
||||
|
||||
Unfortunately the "next" value is always set to 1, i.e. pointing
|
||||
towards argv[1]. Consider POPT_CONTEXT_KEEP_FIRST. If it is set,
|
||||
point to argv[0] just like poptGetContext does.
|
||||
---
|
||||
src/popt.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/popt.c b/src/popt.c
|
||||
index c08b3c9..b7d9478 100644
|
||||
--- a/src/popt.c
|
||||
+++ b/src/popt.c
|
||||
@@ -210,7 +210,10 @@ void poptResetContext(poptContext con)
|
||||
con->os->currAlias = NULL;
|
||||
con->os->nextCharArg = NULL;
|
||||
con->os->nextArg = _free(con->os->nextArg);
|
||||
- con->os->next = 1; /* skip argv[0] */
|
||||
+ if (!(con->flags & POPT_CONTEXT_KEEP_FIRST))
|
||||
+ con->os->next = 1; /* skip argv[0] */
|
||||
+ else
|
||||
+ con->os->next = 0;
|
||||
|
||||
con->numLeftovers = 0;
|
||||
con->nextLeftover = 0;
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,87 +0,0 @@
|
||||
From 7219e1ddc1e8606dda18c1105df0d45d8e8e0e09 Mon Sep 17 00:00:00 2001
|
||||
From: Richard Levitte <richard@levitte.org>
|
||||
Date: Mon, 29 Jun 2020 11:56:00 -0400
|
||||
Subject: [PATCH] Fix incorrect handling of leftovers with poptStuffArgs
|
||||
|
||||
If poptStuffArgs() is used twice with the same context, it will invariably
|
||||
cause memory corruption and possibly memory leaks or a crash.
|
||||
|
||||
Change the allocation of leftOvers so it adapts to the input on the fly
|
||||
instead of trying to pre-allocate it in one go.
|
||||
---
|
||||
src/popt.c | 24 ++++++++++++++++++++++--
|
||||
src/poptint.h | 1 +
|
||||
2 files changed, 23 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/popt.c b/src/popt.c
|
||||
index b7d9478..ab7b54f 100644
|
||||
--- a/src/popt.c
|
||||
+++ b/src/popt.c
|
||||
@@ -168,6 +168,7 @@ poptContext poptGetContext(const char * name, int argc, const char ** argv,
|
||||
con->os->next = 1; /* skip argv[0] */
|
||||
|
||||
con->leftovers = calloc( (size_t)(argc + 1), sizeof(*con->leftovers) );
|
||||
+ con->allocLeftovers = argc + 1;
|
||||
con->options = options;
|
||||
con->aliases = NULL;
|
||||
con->numAliases = 0;
|
||||
@@ -1272,8 +1273,21 @@ int poptGetNextOpt(poptContext con)
|
||||
con->os->nextArg = xstrdup(origOptString);
|
||||
return 0;
|
||||
}
|
||||
- if (con->leftovers != NULL) /* XXX can't happen */
|
||||
- con->leftovers[con->numLeftovers++] = origOptString;
|
||||
+ if (con->leftovers != NULL) { /* XXX can't happen */
|
||||
+ /* One might think we can never overflow the leftovers
|
||||
+ array. Actually, that's true, as long as you don't
|
||||
+ use poptStuffArgs()... */
|
||||
+ if ((con->numLeftovers + 1) >= (con->allocLeftovers)) {
|
||||
+ con->allocLeftovers += 10;
|
||||
+ con->leftovers =
|
||||
+ realloc(con->leftovers,
|
||||
+ sizeof(*con->leftovers) * con->allocLeftovers);
|
||||
+ }
|
||||
+ con->leftovers[con->numLeftovers++]
|
||||
+ = xstrdup(origOptString); /* so a free of a stuffed
|
||||
+ argv doesn't give us a
|
||||
+ dangling pointer */
|
||||
+ }
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1521,6 +1535,8 @@ poptItem poptFreeItems(poptItem items, int nitems)
|
||||
|
||||
poptContext poptFreeContext(poptContext con)
|
||||
{
|
||||
+ int i;
|
||||
+
|
||||
if (con == NULL) return con;
|
||||
poptResetContext(con);
|
||||
|
||||
@@ -1530,7 +1546,11 @@ poptContext poptFreeContext(poptContext con)
|
||||
con->execs = poptFreeItems(con->execs, con->numExecs);
|
||||
con->numExecs = 0;
|
||||
|
||||
+ for (i = 0; i < con->numLeftovers; i++) {
|
||||
+ con->leftovers[i] = _free(&con->leftovers[i]);
|
||||
+ }
|
||||
con->leftovers = _free(con->leftovers);
|
||||
+
|
||||
con->finalArgv = _free(con->finalArgv);
|
||||
con->appName = _free(con->appName);
|
||||
con->otherHelp = _free(con->otherHelp);
|
||||
diff --git a/src/poptint.h b/src/poptint.h
|
||||
index b64e123..d4d6e90 100644
|
||||
--- a/src/poptint.h
|
||||
+++ b/src/poptint.h
|
||||
@@ -94,6 +94,7 @@ struct poptContext_s {
|
||||
struct optionStackEntry * os;
|
||||
poptArgv leftovers;
|
||||
int numLeftovers;
|
||||
+ int allocLeftovers;
|
||||
int nextLeftover;
|
||||
const struct poptOption * options;
|
||||
int restLeftover;
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
From 7182e4618ad5a0186145fc2aa4a98c2229afdfa8 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
|
||||
Date: Wed, 5 Jan 2022 14:51:55 +0100
|
||||
Subject: [PATCH] Fix memory leak regressions in popt 1.18
|
||||
|
||||
Fix memory leak regression introduced in commit
|
||||
7219e1ddc1e8606dda18c1105df0d45d8e8e0e09. Free the actual content, not
|
||||
the array multiple times, and free on reset.
|
||||
---
|
||||
src/popt.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/popt.c b/src/popt.c
|
||||
index 0521c8d..f3f26a3 100644
|
||||
--- a/src/popt.c
|
||||
+++ b/src/popt.c
|
||||
@@ -216,6 +216,9 @@ void poptResetContext(poptContext con)
|
||||
else
|
||||
con->os->next = 0;
|
||||
|
||||
+ for (i = 0; i < con->numLeftovers; i++) {
|
||||
+ con->leftovers[i] = _free(con->leftovers[i]);
|
||||
+ }
|
||||
con->numLeftovers = 0;
|
||||
con->nextLeftover = 0;
|
||||
con->restLeftover = 0;
|
||||
@@ -1534,7 +1537,7 @@ poptContext poptFreeContext(poptContext con)
|
||||
con->numExecs = 0;
|
||||
|
||||
for (i = 0; i < con->numLeftovers; i++) {
|
||||
- con->leftovers[i] = _free(&con->leftovers[i]);
|
||||
+ con->leftovers[i] = _free(con->leftovers[i]);
|
||||
}
|
||||
con->leftovers = _free(con->leftovers);
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
BIN
popt-1.18.tar.gz
BIN
popt-1.18.tar.gz
Binary file not shown.
BIN
popt-1.19.tar.gz
Normal file
BIN
popt-1.19.tar.gz
Normal file
Binary file not shown.
60
popt.spec
60
popt.spec
@ -1,20 +1,22 @@
|
||||
Name: popt
|
||||
Version: 1.18
|
||||
Release: 2
|
||||
Version: 1.19
|
||||
Release: 4
|
||||
Summary: C library for parsing command line parameters
|
||||
License: MIT
|
||||
URL: https://github.com/rpm-software-management/popt/
|
||||
Source0: http://ftp.rpm.org/%{name}/releases/%{name}-1.x/%{name}-%{version}.tar.gz
|
||||
Source0: https://ftp.osuosl.org/pub/rpm/popt/releases/popt-1.x/%{name}-%{version}.tar.gz
|
||||
|
||||
Patch0: fix-obscure-iconv-mis-call-error-path-could-lead-to-.patch
|
||||
Patch1: fix-handle-newly-added-asset-.-call-like-elsewhere.patch
|
||||
Patch2: fix-permit-reading-aliases-remove-left-over-goto-exi.patch
|
||||
Patch3: fix-coverity-CID-1057440-Unused-pointer-value-UNUSED.patch
|
||||
Patch4: backport-Consider-POPT_CONTEXT_KEEP_FIRST-during-reset.patch
|
||||
Patch5: backport-Fix-incorrect-handling-of-leftovers-with-poptStuffAr.patch
|
||||
Patch6: backport-Fix-memory-leak-regressions-in-popt-1.18.patch
|
||||
Patch4: Fix-poptCallbackType-documentation.patch
|
||||
Patch5: Fix-multiple-typos-in-comments.patch
|
||||
Patch6: Fix-potential-double-free-in-test3.c.patch
|
||||
|
||||
BuildRequires: gcc git gettext
|
||||
Patch9000: revert-fix-memory-leak-regressions-in-popt.patch
|
||||
|
||||
BuildRequires: gcc gettext
|
||||
|
||||
%description
|
||||
The popt library exists essentially for parsing command line options. Some
|
||||
@ -27,7 +29,6 @@ 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}
|
||||
|
||||
@ -35,12 +36,7 @@ Obsoletes: %{name}-static < %{version}-%{release}
|
||||
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}.
|
||||
%package_help
|
||||
|
||||
%prep
|
||||
%autosetup -n %{name}-%{version} -p1
|
||||
@ -51,37 +47,47 @@ The %{name}-help package contains doc files for %{name}.
|
||||
|
||||
%install
|
||||
%make_install
|
||||
rm -f %{buildroot}/%{_libdir}/libpopt.la
|
||||
%delete_la
|
||||
mkdir -p %{buildroot}/%{_sysconfdir}/popt.d
|
||||
|
||||
%find_lang %{name}
|
||||
|
||||
%check
|
||||
make check
|
||||
|
||||
%pre
|
||||
|
||||
%preun
|
||||
|
||||
%post -p /sbin/ldconfig
|
||||
|
||||
%postun -p /sbin/ldconfig
|
||||
%make_build check
|
||||
|
||||
%files -f %{name}.lang
|
||||
%license COPYING
|
||||
%{_sysconfdir}/%{name}.d
|
||||
%{_libdir}/lib%{name}.so*
|
||||
%{_libdir}/lib%{name}.so.*
|
||||
|
||||
%files devel
|
||||
%{_includedir}/%{name}.h
|
||||
%{_libdir}/pkgconfig/%{name}.pc
|
||||
%{_libdir}/lib%{name}.so
|
||||
%{_libdir}/lib%{name}.a
|
||||
|
||||
%files help
|
||||
%doc CHANGES README
|
||||
%{_mandir}/man3/%{name}.3.gz
|
||||
%doc README
|
||||
%{_mandir}/man3/*
|
||||
|
||||
%changelog
|
||||
* Fri Aug 16 2024 zhangxingrong <zhangxingrong@uniontech.cn> - 1.19-4
|
||||
- Fix poptCallbackType documentation
|
||||
- Fix multiple typos in comments
|
||||
- Fix potential double-free in test3.c
|
||||
|
||||
* Tue Aug 06 2024 Funda Wang <fundawang@yeah.net> - 1.19-3
|
||||
- Move .so file into devel package
|
||||
|
||||
* Tue Dec 13 2022 Jiayi Chen <1398871225@qq.com> - 1.19-2
|
||||
- Revert fix memory leak regressions in popt introduced by updating to 1.19
|
||||
|
||||
* Fri Nov 18 2022 dillon chen <dillon.chen@gmail.com> - 1.19-1
|
||||
- update to 1.19
|
||||
|
||||
* Thu Aug 18 2022 zhangruifang <zhangruifang1@h-partners.com> - 1.18-3
|
||||
- Revert fix memory leak regressions in popt
|
||||
|
||||
* Mon Aug 15 2022 panxiaohe <panxh.life@foxmail.com> - 1.18-2
|
||||
- Fix incorrect handling of leftovers with poptStuffArgs and memory leak
|
||||
|
||||
|
||||
41
revert-fix-memory-leak-regressions-in-popt.patch
Normal file
41
revert-fix-memory-leak-regressions-in-popt.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From 3258b29e47ec0113048070f72a63a14b6e6437eb Mon Sep 17 00:00:00 2001
|
||||
From: Jiayi Chen <1398871225@qq.com>
|
||||
Date: Tue, 13 Dec 2022 16:09:46 +0800
|
||||
Subject: [PATCH] revert: fix memory leak regressions in popt
|
||||
|
||||
Revert a previous patch in commit 7219e1ddc1e8606dda18c1105df0d45d8e8e0e09,
|
||||
which will cause some problems.
|
||||
|
||||
This patch is automatically introduced by updating version to 1.19.
|
||||
|
||||
https://gitee.com/src-openeuler/popt/issues/I5PL76
|
||||
---
|
||||
src/popt.c | 5 +----
|
||||
1 file changed, 1 insertion(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/popt.c b/src/popt.c
|
||||
index 5710f80..9908ba4 100644
|
||||
--- a/src/popt.c
|
||||
+++ b/src/popt.c
|
||||
@@ -216,9 +216,6 @@ void poptResetContext(poptContext con)
|
||||
else
|
||||
con->os->next = 0;
|
||||
|
||||
- for (i = 0; i < con->numLeftovers; i++) {
|
||||
- con->leftovers[i] = _free(con->leftovers[i]);
|
||||
- }
|
||||
con->numLeftovers = 0;
|
||||
con->nextLeftover = 0;
|
||||
con->restLeftover = 0;
|
||||
@@ -1537,7 +1534,7 @@ poptContext poptFreeContext(poptContext con)
|
||||
con->numExecs = 0;
|
||||
|
||||
for (i = 0; i < con->numLeftovers; i++) {
|
||||
- con->leftovers[i] = _free(con->leftovers[i]);
|
||||
+ con->leftovers[i] = _free(&con->leftovers[i]);
|
||||
}
|
||||
con->leftovers = _free(con->leftovers);
|
||||
|
||||
--
|
||||
2.33.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user