- Hack poptBadOption() to return something semi-meaningful on exec alias
failures (#697435, #710267)
This commit is contained in:
		
							parent
							
								
									f3d7f8c4f4
								
							
						
					
					
						commit
						69ee8930bc
					
				
							
								
								
									
										70
									
								
								popt-1.13-execfail.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								popt-1.13-execfail.patch
									
									
									
									
									
										Normal file
									
								
							| @ -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; | ||||
| @ -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 | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user