Re: [gtk-list] Glib proposal: add strlcpy and strlcat to glib



[note that gtk-devel-list is the proper list for this]

"David Wheeler" <dwheeler@ida.org> writes:
> Greetings.  I proposing adding the "strlcpy" and "strlcat" functions to
> the glib "String Utility Functions" as functions "g_strlcpy" and "g_strlcat".
> 
> These functions support using fixed-length string buffers in a
> safer & easier manner than using strncpy/strncat.  They're a key ingredient
> in OpenBSD's thrust to make their OS secure.  Having these functions
> available makes it easier to create secure code and to avoid bugs.
> The functions strlcpy/strlcat aren't available everywhere, so putting
> them in glib simplifies porting.
> 

g_strndup (), g_snprintf (), and g_strconcat () already guarantee
NULL-termination.

I guess the real question is whether we want strcpy and strcat in
addition to the versions that return new memory. If we want those,
then the NULL-terminating versions are more consistent with standard
glib behavior.

Havoc




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]