]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Check we are writing to a string before checking for enough space.
authorRoy Marples <roy@marples.name>
Fri, 26 Sep 2014 21:13:17 +0000 (21:13 +0000)
committerRoy Marples <roy@marples.name>
Fri, 26 Sep 2014 21:13:17 +0000 (21:13 +0000)
dhcp-common.c

index 1e0d1003fa18e6f1c5bcfe2d331582d667e6f810..569766b12e10f91fce7587d05c00193a977ae1ff 100644 (file)
@@ -331,7 +331,7 @@ print_string(char *s, size_t len, const uint8_t *data, size_t dl)
                }
                ve = svis(v, c, VIS_CSTYLE | VIS_OCTAL,
                    data <= e ? *data : 0, ESCAPE_CHARS);
-               if (len < (size_t)(ve - v) + 1) {
+               if (s && len < (size_t)(ve - v) + 1) {
                        errno = ENOBUFS;
                        return -1;
                }