]> granicus.if.org Git - strace/commitdiff
util.c: add len sanity checks to dumpstr
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 2 May 2018 18:57:58 +0000 (20:57 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 3 May 2018 00:09:53 +0000 (00:09 +0000)
Reported by clang.

* util.c (dumpstr): Check that len is sane.

util.c

diff --git a/util.c b/util.c
index 89856ae8344112335c44e130d6b82ec66c7ff07a..ce81b3173c2e5f60dce2a32edd87b46a041dded3 100644 (file)
--- a/util.c
+++ b/util.c
@@ -928,6 +928,9 @@ dumpstr(struct tcb *const tcp, const kernel_ulong_t addr, const int len)
        const unsigned char *src;
        int i;
 
+       if ((len < 0) || (len > INT_MAX - 16))
+               return;
+
        memset(outbuf, ' ', sizeof(outbuf));
 
        if (strsize < len + 16) {