]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Quote shell special characters.
authorTed Lemon <source@isc.org>
Sat, 24 Jun 2000 06:20:38 +0000 (06:20 +0000)
committerTed Lemon <source@isc.org>
Sat, 24 Jun 2000 06:20:38 +0000 (06:20 +0000)
common/options.c

index 655284079efc49fc372c6614f60d5707e619d14e..e23e617f2b633c6450960d73d822c465d6d46843 100644 (file)
@@ -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;