[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: strlcpy
From:       Grzegorz Borowiak <grzes () gnu ! univ ! gda ! pl>
Date:       2002-12-10 14:50:43
[Download RAW message or body]

On Tue, 10 Dec 2002, Pavel Troller wrote:

> Hi!
>   When compiling kdenetwork of 3_1_BRANCH, it failed with unknown strlcpy()
> function in lanbrowsing/kio_lan. I replaced both its calls with strncpy()
> and it compiled. However, because I never heard of strlcpy(), I don't know
> whether it's OK or not. It's a recent update, formerly there was just
> strcpy() in the code.

When source string is longer than n, strlcpy copies n-1 bytes and adds a
'\0' on the end, while strncpy just copies n bytes and doesn't add a '\0'.
Hence, strlcpy is safer.

                                         _____________
Grzes                  \_______________________|_______________________/
grzes@gnu.univ.gda.pl                         (_)
http://gnu.univ.gda.pl/~grzes/
'Nie krepuj sie Albercik! Usta-usta!'
GCS/M/S/O d- s++:- C UL++++ P+++ L++++$ E- W++ N+ w-- Y++ t--- X-- R- !tv b D+ e+++ r--

<annoy echelon> fbi militia bomb action president mossad delta force
militia action anthrax operation fbi codes top secret </annoy echelon>

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic