Re: library/6287: 64-bit unsafety of qsort(3)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Otto Moerbeek
Date: Sunday, January 24, 2010 - 1:45 pm

The following reply was made to PR library/6287; it has been noted by GNATS.

From: Otto Moerbeek <otto@drijf.net>
To: wd@ics.nara-wu.ac.jp
Cc: gnats@openbsd.org
Subject: Re: library/6287: 64-bit unsafety of qsort(3)
Date: Sun, 24 Jan 2010 21:31:58 +0100

 Hi,
 
 Thanks for the diff, though I do not think it is complete, it's even
 wrong to change r to an unsigned type.
 
 d could be a size_t, yes, but the use of r in line 124 and 125 is as
 an int, its signedness is important.
 
 The use of r furter on is more complex. I really should dig into this
 to find if it should be size_t or ssize_t. Answering that should give
 a clue about the correct diff which also should include changes to
 swapcode() and swapfunc. 
 
 	-Otto
 
 
 
 > --- lib/libc/stdlib/qsort.c.orig	Mon Aug  8 17:05:37 2005
 > +++ lib/libc/stdlib/qsort.c	Wed Jan  6 17:44:28 2010
 > @@ -84,7 +84,8 @@
 >  qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *))
 >  {
 >  	char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
 > -	int d, r, swaptype, swap_cnt;
 > +	size_t d, r;
 > +	int swaptype, swap_cnt;
 >  	char *a = aa;
 >  
 >  loop:	SWAPINIT(a, es);
 > 
 > 
 > >Release-Note:
 > >Audit-Trail:
 > >Unformatted:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: library/6287: 64-bit unsafety of qsort(3), Otto Moerbeek, (Sun Jan 24, 1:45 pm)