Search: Home Bugtraq Vulnerabilities Mailing Lists Jobs Tools Beta Programs
Secure Programming
RE: Are bad developer libraries the problem with M$ software? Nov 16 2002 01:00AM
Michael Howard (mikehow microsoft com) (2 replies)
RE: Are bad developer libraries the problem with M$ software? Nov 16 2002 07:03PM
Frank Knobbe (fknobbe knobbeits com) (3 replies)
Re: Are bad developer libraries the problem with M$ software? Nov 18 2002 07:36PM
Casper Dik (Casper Dik Sun COM) (1 replies)
Re: Are bad developer libraries the problem with M$ software? Nov 18 2002 11:10PM
Andrew Griffiths (andrewg d2 net au) (1 replies)
Re: Are bad developer libraries the problem with M$ software? Nov 19 2002 03:25AM
Frank Knobbe (fknobbe knobbeits com) (3 replies)
Re: Are bad developer libraries the problem with M$ software? Mar 22 2003 09:56AM
Casper Dik (Casper Dik Sun COM)
Re: Are bad developer libraries the problem with M$ software? Nov 19 2002 10:57PM
Andrew Dalgleish (secprog andrewdalgleish dyndns org) (2 replies)
Re: Are bad developer libraries the problem with M$ software? Nov 22 2002 03:31PM
Frank Knobbe (fknobbe knobbeits com)
Re: Are bad developer libraries the problem with M$ software? Nov 22 2002 07:11AM
Valdis Kletnieks vt edu
Re: Are bad developer libraries the problem with M$ software? Nov 18 2002 11:22PM
Andrew Griffiths (andrewg d2 net au)
Re: Are bad developer libraries the problem with M$ software? Nov 18 2002 06:54PM
John Viega (viega securesoftware com) (2 replies)
Re: Are bad developer libraries the problem with M$ software? Nov 18 2002 09:46PM
Frank Knobbe (fknobbe knobbeits com) (1 replies)
On Mon, 2002-11-18 at 12:54, John Viega wrote:

> > #define safe_strcat(dst,src)
> > strncat(dst,src,sizeof(dst))
>
> This is NOT safe or even close to correct. There are two big problems
> here:
>
> 1) sizeof(dst) is very often going to be sizeof(char *) which is 2, no matter
> how much space is malloc'd.

Several of you pointed this out. You are correct that it returns the
size of pointer themselves, not the alloced space. I use definitions
like this every time I work with strings which in my case are always
arrays, not pointers. So while it fits my programming style, it may not
fit others. I apologize to giving the wrong impression with above
thought.

Perhaps we could use another 'sizeof' companion that could return the
size of an allocated piece of memory. For example:
pointer=malloc(1024);
printf("Size of pointer: %ul, size of segment: %ul", sizeof(pointer), alloclen(pointer));

> 2) Even if sizeof(dst) did give the right answer in all cases, your macro
> would still be susceptible to buffer overflows. Bascially, the third
> argument to strcat doesn't do what you seem to think it does. You'd
> need to make that: strncat(dst, src, sizeof(dst)-strlen(dst)-1),

*blush*.... I guess I should have used safe_strncat instead... :)

Frank

[ reply ]
Re: Are bad developer libraries the problem with M$ software? Nov 19 2002 09:31AM
Steffen Dettmer (steffen dett de) (1 replies)
Re: Are bad developer libraries the problem with M$ software? Nov 22 2002 03:35PM
Tim van Erven (tripudium chello nl)
Re: Are bad developer libraries the problem with M$ software? Nov 18 2002 06:26PM
Götz Babin-Ebell (babinebell trustcenter de)
Re: Are bad developer libraries the problem with M$ software? Nov 16 2002 03:29PM
Alex Lambert (alambert webmaster com) (1 replies)
Re: Are bad developer libraries the problem with M$ software? Nov 17 2002 01:46AM
Glynn Clements (glynn clements virgin net)







 

Privacy Statement
Copyright 2009, SecurityFocus