struct ipset_data;
-extern void ipset_strncpy(char *dst, const char *src, size_t len);
+extern void ipset_strlcpy(char *dst, const char *src, size_t len);
extern bool ipset_data_flags_test(const struct ipset_data *data,
uint64_t flags);
extern void ipset_data_flags_set(struct ipset_data *data, uint64_t flags);
}
/**
- * ipset_strncpy - copy the string from src to dst
+ * ipset_strlcpy - copy the string from src to dst
* @dst: the target string buffer
* @src: the source string buffer
* @len: the length of bytes to copy, including the terminating null byte.
* copied. The target is unconditionally terminated by the null byte.
*/
void
-ipset_strncpy(char *dst, const char *src, size_t len)
+ipset_strlcpy(char *dst, const char *src, size_t len)
{
assert(dst);
assert(src);
switch (opt) {
/* Common ones */
case IPSET_SETNAME:
- ipset_strncpy(data->setname, value, IPSET_MAXNAMELEN);
+ ipset_strlcpy(data->setname, value, IPSET_MAXNAMELEN);
break;
case IPSET_OPT_TYPE:
data->type = value;
break;
/* Create-specific options, type */
case IPSET_OPT_TYPENAME:
- ipset_strncpy(data->u.create.typename, value,
+ ipset_strlcpy(data->u.create.typename, value,
IPSET_MAXNAMELEN);
break;
case IPSET_OPT_REVISION:
memcpy(data->u.adt.ether, value, ETH_ALEN);
break;
case IPSET_OPT_NAME:
- ipset_strncpy(data->u.adt.name, value, IPSET_MAXNAMELEN);
+ ipset_strlcpy(data->u.adt.name, value, IPSET_MAXNAMELEN);
break;
case IPSET_OPT_NAMEREF:
- ipset_strncpy(data->u.adt.nameref, value, IPSET_MAXNAMELEN);
+ ipset_strlcpy(data->u.adt.nameref, value, IPSET_MAXNAMELEN);
break;
case IPSET_OPT_IP2:
if (!(data->family == AF_INET || data->family == AF_INET6))
break;
/* Swap/rename */
case IPSET_OPT_SETNAME2:
- ipset_strncpy(data->u.setname2, value, IPSET_MAXNAMELEN);
+ ipset_strlcpy(data->u.setname2, value, IPSET_MAXNAMELEN);
break;
/* flags */
case IPSET_OPT_EXIST:
if (n == NULL)
return -ENOMEM;
- ipset_strncpy(n->name, name, IPSET_MAXNAMELEN);
+ ipset_strlcpy(n->name, name, IPSET_MAXNAMELEN);
n->type = type;
n->family = family;
n->next = NULL;
for (s = setlist; s != NULL; s = s->next) {
if (STREQ(s->name, from)) {
- ipset_strncpy(s->name, to, IPSET_MAXNAMELEN);
+ ipset_strlcpy(s->name, to, IPSET_MAXNAMELEN);
return 0;
}
}
b = s;
}
if (a != NULL && b != NULL) {
- ipset_strncpy(a->name, to, IPSET_MAXNAMELEN);
- ipset_strncpy(b->name, from, IPSET_MAXNAMELEN);
+ ipset_strlcpy(a->name, to, IPSET_MAXNAMELEN);
+ ipset_strlcpy(b->name, from, IPSET_MAXNAMELEN);
return 0;
}