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

index 21e13597a8d3402a57de974c877df1e1e759ca7b..b80ffa1fb47e63d8f33ac2a0460cff004633b1f8 100644 (file)
@@ -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;