lib9, libndb: exclude terminating null from strncpy bound
GCC pointed this out with some "warning: ‘strncpy’ specified bound NUM equals destination size [-Wstringop-truncation]" warnings. Change-Id: Id8408b165f6e4ae82c96a77599d89f658d979b32
This commit is contained in:
parent
540caa5873
commit
e6ed10f25e
2 changed files with 2 additions and 2 deletions
|
|
@ -58,7 +58,7 @@ localtime(long tim)
|
||||||
|
|
||||||
if (zonelookuptinfo(&ti, tim)!=-1) {
|
if (zonelookuptinfo(&ti, tim)!=-1) {
|
||||||
ct = gmtime(tim+ti.tzoff);
|
ct = gmtime(tim+ti.tzoff);
|
||||||
strncpy(ct->zone, ti.zone, sizeof ct->zone);
|
strncpy(ct->zone, ti.zone, sizeof ct->zone - 1);
|
||||||
ct->zone[sizeof ct->zone-1] = 0;
|
ct->zone[sizeof ct->zone-1] = 0;
|
||||||
ct->tzoff = ti.tzoff;
|
ct->tzoff = ti.tzoff;
|
||||||
return ct;
|
return ct;
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ mkptrname(char *ip, char *rip, int rlen)
|
||||||
static void
|
static void
|
||||||
nstrcpy(char *to, char *from, int len)
|
nstrcpy(char *to, char *from, int len)
|
||||||
{
|
{
|
||||||
strncpy(to, from, len);
|
strncpy(to, from, len-1);
|
||||||
to[len-1] = 0;
|
to[len-1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue