public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/popt] pmatilai-v6: - Hack poptBadOption() to return something semi-meaningful on exec alias
@ 2026-11-23 9:55 Panu Matilainen
0 siblings, 0 replies; only message in thread
From: Panu Matilainen @ 2026-11-23 9:55 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/popt
Branch : pmatilai-v6
Commit : 69ee8930bc7a7a05524eb7f69e321f384ee6d7a8
Author : Panu Matilainen <pmatilai@redhat.com>
Date : 2012-08-02T16:16:49+03:00
Stats : +77/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/popt/c/69ee8930bc7a7a05524eb7f69e321f384ee6d7a8?branch=pmatilai-v6
Log:
- Hack poptBadOption() to return something semi-meaningful on exec alias
failures (#697435, #710267)
---
diff --git a/popt-1.13-execfail.patch b/popt-1.13-execfail.patch
new file mode 100644
index 0000000..83b58dc
--- /dev/null
+++ b/popt-1.13-execfail.patch
@@ -0,0 +1,70 @@
+Kludge 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.
+
+diff -up popt-1.13/popt.c.execfail popt-1.13/popt.c
+--- popt-1.13/popt.c.execfail 2012-08-02 16:08:34.762315304 +0300
++++ popt-1.13/popt.c 2012-08-02 16:11:41.352683721 +0300
+@@ -186,6 +186,7 @@ poptContext poptGetContext(const char *
+ con->flags = flags;
+ con->execs = NULL;
+ con->numExecs = 0;
++ con->execFail = NULL;
+ con->finalArgvAlloced = argc * 2;
+ con->finalArgv = calloc( con->finalArgvAlloced, sizeof(*con->finalArgv) );
+ con->execAbsolute = 1;
+@@ -234,6 +235,7 @@ void poptResetContext(poptContext con)
+ 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++) {
+@@ -468,6 +470,7 @@ if (_popt_debug)
+ /*@-nullstate@*/
+ rc = execvp(argv[0], (char *const *)argv);
+ /*@=nullstate@*/
++ con->execFail = xstrdup(argv[0]);
+
+ exit:
+ if (argv) {
+@@ -1194,11 +1197,19 @@ int poptAddItem(poptContext con, poptIte
+ 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)
+diff -up popt-1.13/poptint.h.execfail popt-1.13/poptint.h
+--- popt-1.13/poptint.h.execfail 2012-08-02 16:08:34.000000000 +0300
++++ popt-1.13/poptint.h 2012-08-02 16:12:35.796500122 +0300
+@@ -78,6 +78,7 @@ struct poptContext_s {
+ /*@owned@*/ /*@null@*/
+ poptItem execs;
+ int numExecs;
++ char * execFail;
+ /*@only@*/ /*@null@*/
+ const char ** finalArgv;
+ int finalArgvCount;
diff --git a/popt.spec b/popt.spec
index 55b83ac..44b3770 100644
--- a/popt.spec
+++ b/popt.spec
@@ -1,7 +1,7 @@
Summary: C library for parsing command line parameters
Name: popt
Version: 1.13
-Release: 11%{?dist}
+Release: 12%{?dist}
License: MIT
Group: System Environment/Libraries
URL: http://www.rpm5.org/
@@ -9,6 +9,7 @@ Source: http://www.rpm5.org/files/%{name}/%{name}-%{version}.tar.gz
Patch0: popt-1.13-multilib.patch
Patch1: popt-1.13-popt_fprintf.patch
Patch2: popt-1.13-alias-equal-arg.patch
+Patch3: popt-1.13-execfail.patch
BuildRequires: gettext, doxygen, graphviz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -46,6 +47,7 @@ Install it if you need to link statically with libpopt.
%patch0 -p1 -b .multilib
%patch1 -p1 -b .popt_fprintf
%patch2 -p1 -b .alias-equal-arg
+%patch3 -p1 -b .execfail
%build
%configure --libdir=/%{_lib}
@@ -94,6 +96,10 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/libpopt.a
%changelog
+* Thu Aug 02 2012 Panu Matilainen <pmatilai@redhat.com> - 1.13-12
+- Hack poptBadOption() to return something semi-meaningful on exec alias
+ failures (#697435, #710267)
+
* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.13-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-23 9:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 9:55 [rpms/popt] pmatilai-v6: - Hack poptBadOption() to return something semi-meaningful on exec alias Panu Matilainen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox