Merge tag 'gcc-plugins-v4.9-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / lib / hexdump.c
index 8d74c20..992457b 100644 (file)
@@ -169,11 +169,15 @@ int hex_dump_to_buffer(const void *buf, size_t len, int rowsize, int groupsize,
                }
        } else {
                for (j = 0; j < len; j++) {
-                       if (linebuflen < lx + 3)
+                       if (linebuflen < lx + 2)
                                goto overflow2;
                        ch = ptr[j];
                        linebuf[lx++] = hex_asc_hi(ch);
+                       if (linebuflen < lx + 2)
+                               goto overflow2;
                        linebuf[lx++] = hex_asc_lo(ch);
+                       if (linebuflen < lx + 2)
+                               goto overflow2;
                        linebuf[lx++] = ' ';
                }
                if (j)