From: Craig McQueen Date: Fri, 20 Aug 2021 07:57:18 +0000 (+1000) Subject: Fix parsing of hex/octal escapes in strings (#42) X-Git-Tag: v9.4.1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=247714bcf67a8e765993a8c7d8fa9332bf7a5115;p=thirdparty%2Fdhcpcd.git Fix parsing of hex/octal escapes in strings (#42) --- diff --git a/src/if-options.c b/src/if-options.c index 8ba6635d..dd70c806 100644 --- a/src/if-options.c +++ b/src/if-options.c @@ -321,9 +321,10 @@ parse_str(char *sbuf, size_t slen, const char *str, int flags) break; c[i] = *str++; } - if (c[1] != '\0' && sbuf) { + if (c[1] != '\0') { c[2] = '\0'; - *sbuf++ = (char)strtol(c, NULL, 16); + if (sbuf) + *sbuf++ = (char)strtol(c, NULL, 16); } else l--; break; @@ -335,11 +336,12 @@ parse_str(char *sbuf, size_t slen, const char *str, int flags) break; c[i] = *str++; } - if (c[2] != '\0' && sbuf) { + if (c[2] != '\0') { i = (int)strtol(c, NULL, 8); if (i > 255) i = 255; - *sbuf ++= (char)i; + if (sbuf) + *sbuf++ = (char)i; } else l--; break;