Ethereal-dev: Re: [Ethereal-dev] strcpy harmful, what?

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Ulf Lamping <ulf.lamping@xxxxxx>
Date: Thu, 20 Oct 2005 19:11:07 +0200

Ethereal development <ethereal-dev@xxxxxxxxxxxx> schrieb am 20.10.05 18:38:58:
> 
> /* RANT on */
>     I think I missed the discussion where replacing strcpy with g_sprintf
>     was considered a good idea. 
> /* RANT off */
> 
>     Can someone explain why it's better to call a function which does
> 	- varargs
> 	- parses a string for formatting chars
> 	- calls strncpy!
> 	- calls strlen!
>     is much better than a simple copy.
> 

Where do you read about g_sprintf?!?

It's g_snprintf which is a lot more secure, as it checks if the target area is large enough to hold the resulting string.

A *common* mistake by using strcpy is to unintentionally copy a large source string into a destination area too small to hold it.

Regards, ULFL

__________________________________________________________________________
Erweitern Sie FreeMail zu einem noch leistungsstarkeren E-Mail-Postfach!		
Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131