diff options
author | ache <ache@FreeBSD.org> | 2010-03-09 21:06:01 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2010-03-09 21:06:01 +0000 |
commit | 0cc78f7ab036fb675ad9e4035378afa9446015be (patch) | |
tree | 82a86d65530c1fe80ce05a35cdd49037f4c39b61 /usr.bin/uniq/uniq.c | |
parent | c5fa503cec8f3106fda29df1e39eab08c5416bc9 (diff) | |
download | FreeBSD-src-0cc78f7ab036fb675ad9e4035378afa9446015be.zip FreeBSD-src-0cc78f7ab036fb675ad9e4035378afa9446015be.tar.gz |
Add SIZE_MAX overflow check
Diffstat (limited to 'usr.bin/uniq/uniq.c')
-rw-r--r-- | usr.bin/uniq/uniq.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c index 5416b0b..605bd00 100644 --- a/usr.bin/uniq/uniq.c +++ b/usr.bin/uniq/uniq.c @@ -196,6 +196,8 @@ convert(const char *str) if ((n = mbstowcs(NULL, str, 0)) == (size_t)-1) return (NULL); + if (SIZE_MAX / sizeof(*buf) < n + 1) + errx(1, "conversion buffer length overflow"); if ((buf = malloc((n + 1) * sizeof(*buf))) == NULL) err(1, "malloc"); if (mbstowcs(buf, str, n + 1) != n) |