From: Ted Lemon Date: Sat, 24 Jun 2000 07:24:02 +0000 (+0000) Subject: Quote shell special characters. X-Git-Tag: V2-0-1~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3b68e961de79df2298a5f891290dab2531bd588a;p=thirdparty%2Fdhcp.git Quote shell special characters. --- diff --git a/common/options.c b/common/options.c index 21e13597a..b80ffa1fb 100644 --- a/common/options.c +++ b/common/options.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: options.c,v 1.26.2.10 1999/05/06 21:54:34 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: options.c,v 1.26.2.11 2000/06/24 07:24:02 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #define DHCP_OPTION_DATA @@ -550,8 +550,22 @@ char *pretty_print_option (code, data, len, emit_commas, emit_quotes) case 't': if (emit_quotes) *op++ = '"'; - strcpy (op, (char *)dp); - op += strlen ((char *)dp); + for (; dp < data + len; dp++) { + if (!isascii (*dp) || + !isprint (*dp)) { + sprintf (op, "\\%03o", + *dp); + op += 4; + } else if (*dp == '"' || + *dp == '\'' || + *dp == '$' || + *dp == '`' || + *dp == '\\') { + *op++ = '\\'; + *op++ = *dp; + } else + *op++ = *dp; + } if (emit_quotes) *op++ = '"'; *op = 0;