aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Schultz <das@FreeBSD.org>2008-01-13 02:11:10 +0000
committerDavid Schultz <das@FreeBSD.org>2008-01-13 02:11:10 +0000
commitbadf97cd559de5bb2e86e9f37652c3c1eccf3cbe (patch)
tree8ab753cca46bb4886744da1c76766f12410a0f88 /lib
parentc6eabb5ec17295964e9cce203f9b54efb1d3ae55 (diff)
downloadsrc-badf97cd559de5bb2e86e9f37652c3c1eccf3cbe.tar.gz
src-badf97cd559de5bb2e86e9f37652c3c1eccf3cbe.zip
Use size_t to avoid overflow when sorting arrays larger than 2 GB.
PR: 111085 MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=175259
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdlib/heapsort.c2
-rw-r--r--lib/libc/stdlib/qsort.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/stdlib/heapsort.c b/lib/libc/stdlib/heapsort.c
index 135c48b5e1e8..f65687689c55 100644
--- a/lib/libc/stdlib/heapsort.c
+++ b/lib/libc/stdlib/heapsort.c
@@ -141,7 +141,7 @@ heapsort(vbase, nmemb, size, compar)
size_t nmemb, size;
int (*compar)(const void *, const void *);
{
- int cnt, i, j, l;
+ size_t cnt, i, j, l;
char tmp, *tmp1, *tmp2;
char *base, *k, *p, *t;
diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c
index 65e038c05d75..0958cd3f0fcf 100644
--- a/lib/libc/stdlib/qsort.c
+++ b/lib/libc/stdlib/qsort.c
@@ -111,7 +111,8 @@ qsort(void *a, size_t n, size_t es, cmp_t *cmp)
#endif
{
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
- int d, r, swaptype, swap_cnt;
+ size_t d, r;
+ int swaptype, swap_cnt;
loop: SWAPINIT(a, es);
swap_cnt = 0;