All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [KJ] critical bug in strncpy()
@ 2005-03-28 11:55 Vicente Feito
  2005-03-28 14:34 ` walter harms
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Vicente Feito @ 2005-03-28 11:55 UTC (permalink / raw)
  To: kernel-janitors

Hi walter,
I think the main problem is the fact that tmp++ keeps going when src++ stops, 
this can be fixed like this:
if ((*tmp = *src) != 0) { src++; tmp++; } <--- just adding brackets
with that I think you have all bases covered, otherwise tmp keeps 
incrementing, which doesn't have any sense in this case.
The other issue is the fact that if strlen(src) > count you get a non null 
terminated string, but that's the way it has been made.
And the final issue afaik is the waste of cpu cycles when the strings have 
ended copying themselves but the count is still > 0, but that's not a 
security issue.

Vicente.


On Monday 28 March 2005 02:34 pm, walter harms wrote:
> int main()
> {
> char *src="15" ;
> char dst[]="123";
>
> K_strncpy(dst,src,500);
>
> }
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-03-28 21:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-28 11:55 [KJ] critical bug in strncpy() Vicente Feito
2005-03-28 14:34 ` walter harms
2005-03-28 15:03 ` Ryan Anderson
2005-03-28 15:31 ` walter harms
2005-03-28 18:18 ` Ryan Anderson
2005-03-28 19:19 ` walter harms
2005-03-28 21:26 ` Matthew Wilcox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.