diff options
author | 2014-10-11 03:02:59 +0000 | |
---|---|---|
committer | 2014-10-11 03:02:59 +0000 | |
commit | df614fb10ef744ebcf5bb1cb349b8385d0815ac7 (patch) | |
tree | 75a804db56c570c1113d5cc9a5fc96f1740538c1 /usr.bin/sort/sort.c | |
parent | Userland reallocarray() audit. (diff) | |
download | wireguard-openbsd-df614fb10ef744ebcf5bb1cb349b8385d0815ac7.tar.xz wireguard-openbsd-df614fb10ef744ebcf5bb1cb349b8385d0815ac7.zip |
Userland reallocarray() audit.
Avoid potential integer overflow in the size argument of malloc() and
realloc() by using reallocarray() to avoid unchecked multiplication.
ok deraadt@
Diffstat (limited to 'usr.bin/sort/sort.c')
-rw-r--r-- | usr.bin/sort/sort.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c index 793bfea99bc..f7a41e98bfa 100644 --- a/usr.bin/sort/sort.c +++ b/usr.bin/sort/sort.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sort.c,v 1.41 2013/11/13 15:07:27 deraadt Exp $ */ +/* $OpenBSD: sort.c,v 1.42 2014/10/11 03:02:59 doug Exp $ */ /*- * Copyright (c) 1993 @@ -82,8 +82,8 @@ static void usage(char *); #define CHECK_NFIELDS \ if (++nfields == ND) { \ ND += 10; \ - if ((p = realloc(fldtab, \ - ND * sizeof(*fldtab))) == NULL) \ + if ((p = reallocarray(fldtab, ND, \ + sizeof(*fldtab))) == NULL) \ errx(2, "cannot allocate memory"); \ ftpos = p + (ftpos - fldtab); \ fldtab = p; \ |