Don't crash on un-wordexp()'able arguments!
We run shell expansion on configuration arguments, e.g. `printcommand`, but it would crash if the config file's input was not quoted, e.g. printcommand=pstopdf - - > $HOME/print.pdf Now echo'ing an error to stderr and moving on. Be sure to quote, e.g. printcommand="pstopdf - - > $HOME/print.pdf"
This commit is contained in:
parent
0e359a1fba
commit
fe33acc716
2 changed files with 20 additions and 3 deletions
|
|
@ -94,6 +94,12 @@ https://tuxpaint.org/
|
||||||
data beyond the end of the data (copied from the original PNG).
|
data beyond the end of the data (copied from the original PNG).
|
||||||
Bill Kendrick <bill@newbreedsoftware.com>
|
Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
|
|
||||||
|
* Shell expansion (via wordexp()) of configuration options containing
|
||||||
|
spaces (e.g., `printcommand=ps2pdf - - > $HOME/print.pdf`) would
|
||||||
|
fail & cause a crash. It now shows an error and recommends adding
|
||||||
|
quotes. (e.g., `printcommand="ps2pdf - - > $HOME/print.pdf"`)
|
||||||
|
Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
|
|
||||||
* Localization Updates:
|
* Localization Updates:
|
||||||
---------------------
|
---------------------
|
||||||
* Russian translaton
|
* Russian translaton
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
(See COPYING.txt)
|
(See COPYING.txt)
|
||||||
|
|
||||||
June 14, 2002 - June 1, 2023
|
June 14, 2002 - June 3, 2023
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
@ -19648,6 +19648,8 @@ void do_print(void)
|
||||||
else
|
else
|
||||||
pcmd = printcommand;
|
pcmd = printcommand;
|
||||||
|
|
||||||
|
DEBUG_PRINTF("printcmd: %s\n", printcommand);
|
||||||
|
|
||||||
pi = popen(pcmd, "w");
|
pi = popen(pcmd, "w");
|
||||||
|
|
||||||
if (pi == NULL)
|
if (pi == NULL)
|
||||||
|
|
@ -27752,8 +27754,17 @@ static void parse_file_options(struct cfginfo *restrict tmpcfg, const char *file
|
||||||
wordexp_t result;
|
wordexp_t result;
|
||||||
|
|
||||||
wordexp(arg, &result, 0);
|
wordexp(arg, &result, 0);
|
||||||
arg = strdup(result.we_wordv[0]);
|
if (result.we_wordv != NULL)
|
||||||
wordfree(&result);
|
{
|
||||||
|
DEBUG_PRINTF("wordexp result.we_wordv of `%s` was `%s`\n", str, result.we_wordv[0]);
|
||||||
|
arg = strdup(result.we_wordv[0]);
|
||||||
|
wordfree(&result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Shell expansion of `%s` failed! (You probably need to wrap it in quotes (\")!)\n", str);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue