]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Correctly quote shell meta-characters.
authorTed Lemon <source@isc.org>
Wed, 28 Jun 2000 23:35:22 +0000 (23:35 +0000)
committerTed Lemon <source@isc.org>
Wed, 28 Jun 2000 23:35:22 +0000 (23:35 +0000)
common/options.c

index e23e617f2b633c6450960d73d822c465d6d46843..fdc8d4bb0522c5fd62c52f6e805e46687c0e958e 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$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";
+"$Id: options.c,v 1.62 2000/06/28 23:35:22 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #define DHCP_OPTION_DATA
@@ -672,21 +672,21 @@ const char *pretty_print_option (code, data, len, emit_commas, emit_quotes)
                              case 't':
                                if (emit_quotes)
                                        *op++ = '"';
-                               for (k = 0; dp [k]; k++) {
-                                       if (!isascii (dp [k]) ||
-                                           !isprint (dp [k])) {
+                               for (; dp < data + len; dp++) {
+                                       if (!isascii (*dp) ||
+                                           !isprint (*dp)) {
                                                sprintf (op, "\\%03o",
-                                                        dp [k]);
+                                                        *dp);
                                                op += 4;
-                                       } else if (dp [k] == '"' ||
-                                                  dp [k] == '\'' ||
-                                                  dp [k] == '$' ||
-                                                  dp [k] == '`' ||
-                                                  dp [k] == '\\') {
+                                       } else if (*dp == '"' ||
+                                                  *dp == '\'' ||
+                                                  *dp == '$' ||
+                                                  *dp == '`' ||
+                                                  *dp == '\\') {
                                                *op++ = '\\';
-                                               *op++ = dp [k];
+                                               *op++ = *dp;
                                        } else
-                                               *op++ = dp [k];
+                                               *op++ = *dp;
                                }
                                if (emit_quotes)
                                        *op++ = '"';