gnokii-users
[Top][All Lists]
Advanced

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

Re: [PATCH] Kill strcpy and strcat


From: Pawel Kot
Subject: Re: [PATCH] Kill strcpy and strcat
Date: Wed, 7 Nov 2007 14:26:40 +0100

Hi,

On 11/7/07, Daniele Forsi <address@hidden> wrote:
> Pawel Kot wrote to Bastien Nocera:
>
> > For strncpy() you need also to ensure, the destination string will be
> > null-terminated. I'm working already for the patch for whole gnokii.
>
> there are SAFE_STRNCPY and SAFE_STRNCPY_SIZEOF in ./include/misc.h
> I used SAFE_STRNCPY in ./common/phones/pcsc.c

Maybe somebody could tell me if there is a difference between:
snprintf(buf, sizeof(buf), "%s", some_string);
and
strncpy(buf, some_string, sizeof(buf));
buf[sizeof(buf) - 1] = 0;

That should do essentially the same thing, but maybe I'm missing
something. I'd like to encourage one way doing this.

BTW. We check in configure script if snprintf() produces
null-terminated string and if not, we provide working version.

take care,
pkot
-- 
Pawel Kot




reply via email to

[Prev in Thread] Current Thread [Next in Thread]