From: Ted Lemon Date: Fri, 29 Sep 2000 19:58:24 +0000 (+0000) Subject: Don't print trailing NUL when printing a text string. X-Git-Tag: V3-BETA-2-PATCH-6~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=723deaee8fd2e591695a5123cddf975a3f8f8de1;p=thirdparty%2Fdhcp.git Don't print trailing NUL when printing a text string. --- diff --git a/common/options.c b/common/options.c index 0804d3f9b..637a33738 100644 --- a/common/options.c +++ b/common/options.c @@ -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 == '$' ||