]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Don't print trailing NUL when printing a text string.
authorTed Lemon <source@isc.org>
Fri, 29 Sep 2000 19:58:24 +0000 (19:58 +0000)
committerTed Lemon <source@isc.org>
Fri, 29 Sep 2000 19:58:24 +0000 (19:58 +0000)
common/options.c

index 0804d3f9bd1c0249ee2646b0cde3a9809fc35e33..637a337386e21a36b7891930e9a4ed9af9734eda 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: options.c,v 1.64 2000/09/16 20:01:07 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: options.c,v 1.65 2000/09/29 19:58:24 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #define DHCP_OPTION_DATA
@@ -680,9 +680,13 @@ const char *pretty_print_option (code, data, len, emit_commas, emit_quotes)
                                for (; dp < data + len; dp++) {
                                        if (!isascii (*dp) ||
                                            !isprint (*dp)) {
-                                               sprintf (op, "\\%03o",
-                                                        *dp);
-                                               op += 4;
+                                               /* Skip trailing NUL. */
+                                           if (dp + 1 != data + len ||
+                                               *dp != 0) {
+                                                   sprintf (op, "\\%03o",
+                                                            *dp);
+                                                   op += 4;
+                                           }
                                        } else if (*dp == '"' ||
                                                   *dp == '\'' ||
                                                   *dp == '$' ||