The truncate of the strlcpy() here was a *desired* side effect.
strlcpy()/strlcat() should never be used like that. Be more
explicit about the truncation and don't use strlcpy here.
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Sat Mar 31 07:59:16 CEST 2012 on sn-devel-104
*/
if (p && (p > str) && ((scope_id = if_nametoindex(p+1)) != 0)) {
- size_t len = MIN(PTR_DIFF(p,str)+1, sizeof(addr));
- if (strlcpy(addr, str, len) >= len) {
- /* Truncate. */
+ /* Length of string we want to copy.
+ This is IP:v6:addr (removing the %ifname).
+ */
+ size_t len = PTR_DIFF(p,str);
+
+ if (len+1 > sizeof(addr)) {
+ /* string+nul too long for array. */
return false;
}
+ memcpy(addr, str, len);
+ addr[len] = '\0';
+
str = addr;
}
}