From: Eugene Syromyatnikov Date: Wed, 2 May 2018 18:57:58 +0000 (+0200) Subject: util.c: add len sanity checks to dumpstr X-Git-Tag: v4.23~234 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=973687fd92241c1aaf2358513b8b5d8396da82f1;p=strace util.c: add len sanity checks to dumpstr Reported by clang. * util.c (dumpstr): Check that len is sane. --- diff --git a/util.c b/util.c index 89856ae8..ce81b317 100644 --- 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) {