diff options
author | deraadt <> | 2007-09-02 15:19:18 +0000 |
---|---|---|
committer | deraadt <> | 2007-09-02 15:19:18 +0000 |
commit | 4dce4206f0cafd0811f23aedc04a436aa9d145c1 (patch) | |
tree | 9bdb3d7b5724b183b1a397bf8f071fac1f056834 /src/lib/libc/stdlib/radixsort.c | |
parent | 7c27b50830c6058e8a7d8f2a3398c9c2f429b9f4 (diff) | |
download | openbsd-4dce4206f0cafd0811f23aedc04a436aa9d145c1.tar.gz openbsd-4dce4206f0cafd0811f23aedc04a436aa9d145c1.tar.bz2 openbsd-4dce4206f0cafd0811f23aedc04a436aa9d145c1.zip |
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'src/lib/libc/stdlib/radixsort.c')
-rw-r--r-- | src/lib/libc/stdlib/radixsort.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libc/stdlib/radixsort.c b/src/lib/libc/stdlib/radixsort.c index 0b2ff27044..49d03b52d5 100644 --- a/src/lib/libc/stdlib/radixsort.c +++ b/src/lib/libc/stdlib/radixsort.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: radixsort.c,v 1.8 2005/08/08 08:05:37 espie Exp $ */ | 1 | /* $OpenBSD: radixsort.c,v 1.9 2007/09/02 15:19:17 deraadt Exp $ */ |
2 | /*- | 2 | /*- |
3 | * Copyright (c) 1990, 1993 | 3 | * Copyright (c) 1990, 1993 |
4 | * The Regents of the University of California. All rights reserved. | 4 | * The Regents of the University of California. All rights reserved. |
@@ -104,7 +104,7 @@ sradixsort(const u_char **a, int n, const u_char *tab, u_int endch) | |||
104 | if (n < THRESHOLD) | 104 | if (n < THRESHOLD) |
105 | simplesort(a, n, 0, tr, endch); | 105 | simplesort(a, n, 0, tr, endch); |
106 | else { | 106 | else { |
107 | if ((ta = malloc(n * sizeof(a))) == NULL) | 107 | if ((ta = calloc(n, sizeof(a))) == NULL) |
108 | return (-1); | 108 | return (-1); |
109 | r_sort_b(a, ta, n, 0, tr, endch); | 109 | r_sort_b(a, ta, n, 0, tr, endch); |
110 | free(ta); | 110 | free(ta); |