[Gllug] C function strcasecmp

home at alexhudson.com home at alexhudson.com
Wed Jul 25 17:01:44 UTC 2001


On Wed, Jul 25, 2001 at 05:31:14PM +0100, David Spencer wrote:
> I didn't mean the NDC caused the BO....look at the sequence of events

I know how to cause a buffer overflow ;)

BTW .. it seems we agree here  - we weren't talking about writes, only
reads, since we were talking about strncmp?

> the buffer that's just overflowed").  In Losedows, an editbox can hold
> 32K, or 4G in NT (or is it 2G. It's a lot anyway).

2G I think - I32 user space limit, like Linux (I think both Linux and NT doa
50/50 split).

> Oh, and strn* _does_ protect you if it's used correctly; consider the
> following:
> 
> char x[5];
> strncpy(x, "Hello world", 4); (param order?)
> 
> No buffer overflow there.

Until you come to do something with your unterminated string you mean? :P
(Param order correct according to my man page :) It doesn't protect you at
all - it gives you a means to protect yourself. 

And also, a common programming error is something like:

char x[5];
x[0] = 0; // zero length string :-)
strncat (x, "Hello world", 5);

That's apparently pretty common, even though a strncpy(x, "Hello..", 5)
wouldn't have the same problem (until you come to treat the buffer as a
string of course).

strn* isn't the answer to all prayers, but it's better than nothing.

Cheers,

Alex.

-- 

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list