From: Jeremy Sowden Date: Sun, 22 Aug 2021 16:35:51 +0000 (+0100) Subject: xt_condition: use `xt_check_proc_name` to validate /proc file name X-Git-Tag: v3.19~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=068a6ed71ff9d1c5ea3e56d423e591cb08265de1;p=thirdparty%2Fxtables-addons.git xt_condition: use `xt_check_proc_name` to validate /proc file name 4.16 introduced a standard function to do the job, so let's use it. Signed-off-by: Jeremy Sowden --- diff --git a/extensions/xt_condition.c b/extensions/xt_condition.c index c2c4867..1d9d735 100644 --- a/extensions/xt_condition.c +++ b/extensions/xt_condition.c @@ -135,9 +135,7 @@ static int condition_mt_check(const struct xt_mtchk_param *par) struct condition_net *condition_net = condition_pernet(par->net); /* Forbid certain names */ - if (*info->name == '\0' || *info->name == '.' || - info->name[sizeof(info->name)-1] != '\0' || - memchr(info->name, '/', sizeof(info->name)) != NULL) { + if (xt_check_proc_name(info->name, sizeof(info->name))) { printk(KERN_INFO KBUILD_MODNAME ": name not allowed or too " "long: \"%.*s\"\n", (unsigned int)sizeof(info->name), info->name);