summaryrefslogtreecommitdiffstats
path: root/usr.bin/uniq
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2010-03-09 21:06:01 +0000
committerache <ache@FreeBSD.org>2010-03-09 21:06:01 +0000
commit0cc78f7ab036fb675ad9e4035378afa9446015be (patch)
tree82a86d65530c1fe80ce05a35cdd49037f4c39b61 /usr.bin/uniq
parentc5fa503cec8f3106fda29df1e39eab08c5416bc9 (diff)
downloadFreeBSD-src-0cc78f7ab036fb675ad9e4035378afa9446015be.zip
FreeBSD-src-0cc78f7ab036fb675ad9e4035378afa9446015be.tar.gz
Add SIZE_MAX overflow check
Diffstat (limited to 'usr.bin/uniq')
-rw-r--r--usr.bin/uniq/uniq.c2
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)
OpenPOWER on IntegriCloud