]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix bounds check.
authorRoy Marples <roy@marples.name>
Mon, 29 Sep 2014 13:24:09 +0000 (13:24 +0000)
committerRoy Marples <roy@marples.name>
Mon, 29 Sep 2014 13:24:09 +0000 (13:24 +0000)
dhcp-common.c

index 3e356c9dc353c25dd0a2f07185cbb5e598fa45ba..915cad47da1bf8b3bb0746e213d481f6bbb6dfbd 100644 (file)
@@ -336,11 +336,11 @@ print_string(char *s, size_t len, int flags, const uint8_t *data, size_t dl)
                else
                        ve = vis(v, c, VIS_CSTYLE | VIS_OCTAL,
                            data <= e ? *data : 0);
-               if (s && len < (size_t)(ve - v) + 1) {
+               bytes += (size_t)(ve - v);
+               if (s && len < bytes + 1) {
                        errno = ENOBUFS;
                        return -1;
                }
-               bytes += (size_t)(ve - v);
                if (s) {
                        vp = v;
                        while (vp != ve)