svn commit: r265367 - head/lib/libc/regex

Warner Losh imp at bsdimp.com
Mon May 5 22:20:05 UTC 2014


On May 5, 2014, at 4:10 PM, Pedro Giffuni <pfg at FreeBSD.org> wrote:

> El 5/5/2014 4:21 PM, David Chisnall escribió:
>> On 5 May 2014, at 20:49, Pedro Giffuni <pfg at FreeBSD.org> wrote:
>> 
>>> Yes, but I reverted it because there are other ways to check for overflows without the performance hit.
>> 
> 
> FWIW, in this particular case I think the overflow simply doesn't happen: apparently it is easier to be hit by a DoS first.
> 
> 
>> Do we have a good reusable routine for doing this somewhere?  Clang and gcc both have some idiom recognisers that try to spot when people are attempting to do this.  Clang also has a builtin, which would be good to use when available.  Overflow checking is very cheap on modern CPUs (add, branch on carry), so it would be nice if we could start looking for this malloc() and realloc() pattern and replacing the multiply with something that checks for the error.
>> 
> 
> We don't. OpenBSD introduced an extension: reallocarray().

We do. reallocf(), which first appeared in FreeBSD 3.0.

Warner



More information about the svn-src-head mailing list