From: Ted Lemon Date: Sat, 24 Jun 2000 06:20:38 +0000 (+0000) Subject: Quote shell special characters. X-Git-Tag: V3-BETA-2-PATCH-1~125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac4b9d4b9ae77171ad50321bea2b52f39415aa47;p=thirdparty%2Fdhcp.git Quote shell special characters. --- diff --git a/common/options.c b/common/options.c index 655284079..e23e617f2 100644 --- a/common/options.c +++ b/common/options.c @@ -43,7 +43,7 @@ #ifndef lint static char copyright[] = -"$Id: options.c,v 1.60 2000/05/17 16:04:02 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n"; +"$Id: options.c,v 1.61 2000/06/24 06:20:38 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #define DHCP_OPTION_DATA @@ -672,8 +672,22 @@ const char *pretty_print_option (code, data, len, emit_commas, emit_quotes) case 't': if (emit_quotes) *op++ = '"'; - strcpy (op, (const char *)dp); - op += strlen ((const char *)dp); + for (k = 0; dp [k]; k++) { + if (!isascii (dp [k]) || + !isprint (dp [k])) { + sprintf (op, "\\%03o", + dp [k]); + op += 4; + } else if (dp [k] == '"' || + dp [k] == '\'' || + dp [k] == '$' || + dp [k] == '`' || + dp [k] == '\\') { + *op++ = '\\'; + *op++ = dp [k]; + } else + *op++ = dp [k]; + } if (emit_quotes) *op++ = '"'; *op = 0;