From 18b1ed14673cfa7b72a67c97dacdf3dde4b86238 Mon Sep 17 00:00:00 2001 From: morgana Date: Wed, 28 Jan 2009 18:03:15 +0000 Subject: [PATCH 1/1] Expand list of shell metacharacters to escape in variable substitution. Courtesty of Nico Golde. --- etc/papd/lp.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/etc/papd/lp.c b/etc/papd/lp.c index c6572cc9..ee7d7274 100644 --- a/etc/papd/lp.c +++ b/etc/papd/lp.c @@ -1,5 +1,5 @@ /* - * $Id: lp.c,v 1.21 2009-01-21 02:43:46 didg Exp $ + * $Id: lp.c,v 1.22 2009-01-28 18:03:15 morgana Exp $ * * Copyright (c) 1990,1994 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -217,7 +217,26 @@ size_t used = 0; case '$': case '\\': case '"': + case ';': + case '&': + case '(': + case ')': + case ' ': + case '*': + case '#': + case '|': + case '>': + case '<': + case '[': + case ']': + case '{': + case '}': + case '^': + case '?': + case '~': case '`': + case '\x0A': + case '\xFF': if (used + 2 > bsize ) return used; *dest = '\\'; @@ -247,9 +266,9 @@ static char* pipexlate(char *src) if (!src) return NULL; - memset(dest, 0, MAXPATHLEN +1); + memset(dest, 0, sizeof(destbuf)); if ((p = strchr(src, '%')) == NULL) { /* nothing to do */ - strncpy(dest, src, MAXPATHLEN); + strncpy(dest, src, sizeof(dest) - 1); return destbuf; } /* first part of the path. copy and forward to the next variable. */ -- 2.39.2