From bc77380243faf687e78a919651ecb5e682155acc Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Tue, 26 Mar 2024 08:55:10 +0000 Subject: [PATCH] ANDROID: xt_quota2: Replace strlcpy() with compatible and safer variant strscpy() strlcpy() has now been formally removed from the kernel due to the risks it poses. Let's follow suit and convert over to strscpy(). Fixes the following build error: net/netfilter/xt_quota2.c:114:3: error: call to undeclared library function 'strlcpy' with type 'unsigned long (char *, const char *, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 114 | strlcpy(pm->prefix, prefix, sizeof(pm->prefix)); Fixes: d26270061ae6 ("string: Remove strlcpy()") Signed-off-by: Lee Jones Change-Id: I33990ba6ddd60901f21ea1c6e60675c7c1262c54 --- net/netfilter/xt_quota2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/netfilter/xt_quota2.c b/net/netfilter/xt_quota2.c index 27acc866befb..e05616ee2be9 100644 --- a/net/netfilter/xt_quota2.c +++ b/net/netfilter/xt_quota2.c @@ -111,11 +111,11 @@ static void quota2_log(unsigned int hooknum, __net_timestamp((struct sk_buff *)skb); pm->hook = hooknum; if (prefix != NULL) - strlcpy(pm->prefix, prefix, sizeof(pm->prefix)); + strscpy(pm->prefix, prefix, sizeof(pm->prefix)); if (in) - strlcpy(pm->indev_name, in->name, sizeof(pm->indev_name)); + strscpy(pm->indev_name, in->name, sizeof(pm->indev_name)); if (out) - strlcpy(pm->outdev_name, out->name, sizeof(pm->outdev_name)); + strscpy(pm->outdev_name, out->name, sizeof(pm->outdev_name)); NETLINK_CB(log_skb).dst_group = 1; pr_debug("throwing 1 packets to netlink group 1\n"); @@ -187,7 +187,7 @@ q2_new_counter(const struct xt_quota_mtinfo2 *q, bool anon) if (!anon) { INIT_LIST_HEAD(&e->list); atomic_set(&e->ref, 1); - strlcpy(e->name, q->name, sizeof(e->name)); + strscpy(e->name, q->name, sizeof(e->name)); } return e; }