Messages in this thread | ![/](/images/icornerl.gif) | | Date | Fri, 28 Nov 2003 09:26:42 +0900 (JST) | Subject | Re: [PATCH 2.6]: IPv6: strcpy -> strlcpy | From | YOSHIFUJI Hideaki / 吉藤英明 <> |
| |
In article <20031128.092326.39861126.yoshfuji@linux-ipv6.org> (at Fri, 28 Nov 2003 09:23:26 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org> says:
> 2) memset(dst, 0, len); > strncpy(dst, src, len);
oops, this should be
memset(dst, 0, len); if (len > 0) strncpy(dst, src, len - 1);
> 3) if (len) > strncpy(dst, src, len - 1); > dst[len] = 0; > > (or, say, strncpy0()).
Note: in this case, we need to fix strncpy() first to zero-out rest of destination buffer.
--yoshfuji - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| ![\](/images/icornerr.gif) |