add some upstream patchs

(cherry picked from commit 22ce5d5a6b1a1b65cfcff432fce783673a88ba5f)
This commit is contained in:
zhangxingrong 2024-08-16 10:26:08 +08:00 committed by openeuler-sync-bot
parent 034e622740
commit 12035d81a4
4 changed files with 138 additions and 1 deletions

View 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

View 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

View 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++)

View File

@ -1,6 +1,6 @@
Name: popt
Version: 1.19
Release: 3
Release: 4
Summary: C library for parsing command line parameters
License: MIT
URL: https://github.com/rpm-software-management/popt/
@ -10,6 +10,9 @@ 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: Fix-poptCallbackType-documentation.patch
Patch5: Fix-multiple-typos-in-comments.patch
Patch6: Fix-potential-double-free-in-test3.c.patch
Patch9000: revert-fix-memory-leak-regressions-in-popt.patch
@ -68,6 +71,11 @@ mkdir -p %{buildroot}/%{_sysconfdir}/popt.d
%{_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