Commit 5c72b4c6 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Jakub Kicinski

openvswitch: Use string_is_terminated() helper

Use string_is_terminated() helper instead of cpecific memchr() call.
This shows better the intention of the call.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Link: https://lore.kernel.org/r/20230208133153.22528-3-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d4545bf9
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/udp.h> #include <linux/udp.h>
#include <linux/sctp.h> #include <linux/sctp.h>
#include <linux/static_key.h> #include <linux/static_key.h>
#include <linux/string_helpers.h>
#include <net/ip.h> #include <net/ip.h>
#include <net/genetlink.h> #include <net/genetlink.h>
#include <net/netfilter/nf_conntrack_core.h> #include <net/netfilter/nf_conntrack_core.h>
...@@ -1383,7 +1384,7 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info, ...@@ -1383,7 +1384,7 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
#endif #endif
case OVS_CT_ATTR_HELPER: case OVS_CT_ATTR_HELPER:
*helper = nla_data(a); *helper = nla_data(a);
if (!memchr(*helper, '\0', nla_len(a))) { if (!string_is_terminated(*helper, nla_len(a))) {
OVS_NLERR(log, "Invalid conntrack helper"); OVS_NLERR(log, "Invalid conntrack helper");
return -EINVAL; return -EINVAL;
} }
...@@ -1404,7 +1405,7 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info, ...@@ -1404,7 +1405,7 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
#ifdef CONFIG_NF_CONNTRACK_TIMEOUT #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
case OVS_CT_ATTR_TIMEOUT: case OVS_CT_ATTR_TIMEOUT:
memcpy(info->timeout, nla_data(a), nla_len(a)); memcpy(info->timeout, nla_data(a), nla_len(a));
if (!memchr(info->timeout, '\0', nla_len(a))) { if (!string_is_terminated(info->timeout, nla_len(a))) {
OVS_NLERR(log, "Invalid conntrack timeout"); OVS_NLERR(log, "Invalid conntrack timeout");
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment