Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110714175509.GK16618@brightrain.aerifal.cx>
Date: Thu, 14 Jul 2011 13:55:09 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: cluts: strerror_r() test

On Thu, Jul 14, 2011 at 12:41:35PM +0200, Luka Marčetić wrote:
> one). Strerror_r implementations are free to redirect a passed
> pointer to immutable memory if size(buflen) argument is sufficiently

I don't see how this can be. sterror_r (the correct standard function
not the GNU bastardization) has no way of returning a pointer to a
string. Due to the interface design, it must write into the provided
buffer. By the way, this is another reason _POSIX_C_SOURCE or
_XOPEN_SOURCE must be defined - glibc likes to give you nonstandard
GNU functions by default...

> large. Of course, wanting to write to s[size-1] would SIGSEGV in

Actually it would probably just corrupt malloc data structures and
lead to havoc much later in the program. To test you could use a trick
like the string function tests, but that's really overkill. Just
allocating a buffer that's large enough, pre-filling it with an
unusual value, and calling the function with a shorter length
parameter should work. Then you can check that none of the fill bytes
were clobbered past the allowed length.

I hope this makes sense...

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.