NLA_NUL_STRING was introduced in 2.6.19.
[OFP_DEFINE([HAVE_SKBUFF_HEADER_HELPERS])])
OFP_GREP_IFELSE([$KSRC26/include/linux/skbuff.h], [raw],
[OFP_DEFINE([HAVE_MAC_RAW])])
+ OFP_GREP_IFELSE([$KSRC26/include/net/netlink.h], [NLA_NUL_STRING],
+ [OFP_DEFINE([HAVE_NLA_NUL_STRING])])
if cmp -s datapath/linux-2.6/kcompat.h.new \
datapath/linux-2.6/kcompat.h >/dev/null 2>&1; then
rm datapath/linux-2.6/kcompat.h.new
const char *dp_name = info->attrs[DP_GENL_A_DP_NAME] ?
nla_data(info->attrs[DP_GENL_A_DP_NAME]) : NULL;
+ if (VERIFY_NUL_STRING(info->attrs[DP_GENL_A_DP_NAME]))
+ return -EINVAL;
+
if ((dp_idx == -1) && (!dp_name))
return -EINVAL;
const char *dp_name = info->attrs[DP_GENL_A_DP_NAME] ?
nla_data(info->attrs[DP_GENL_A_DP_NAME]) : NULL;
+ if (VERIFY_NUL_STRING(info->attrs[DP_GENL_A_DP_NAME]))
+ return ERR_PTR(-EINVAL);
+
if (dp_idx != -1) {
struct datapath *dp = dp_get_by_idx(dp_idx);
if (!dp)
struct net_device *port;
int err;
- if (!info->attrs[DP_GENL_A_PORTNAME])
+ if (!info->attrs[DP_GENL_A_PORTNAME] ||
+ VERIFY_NUL_STRING(info->attrs[DP_GENL_A_PORTNAME]))
return -EINVAL;
/* Get datapath. */
#define nla_for_each_nested(pos, nla, rem) \
nla_for_each_attr(pos, nla_data(nla), nla_len(nla), rem)
+static inline int VERIFY_NUL_STRING(struct nlattr *attr)
+{
+ return 0;
+}
+
#endif
--- /dev/null
+#ifndef __NET_NETLINK_WRAPPER_H
+#define __NET_NETLINK_WRAPPER_H 1
+
+#include_next <net/netlink.h>
+
+#ifndef HAVE_NLA_NUL_STRING
+#define NLA_NUL_STRING NLA_STRING
+
+static inline int VERIFY_NUL_STRING(struct nlattr *attr)
+{
+ return (!attr || (nla_len(attr)
+ && memchr(nla_data(attr), '0', nla_len(attr)))
+ ? 0 : EINVAL);
+}
+#else
+static inline int VERIFY_NUL_STRING(struct nlattr *attr)
+{
+ return 0;
+}
+#endif /* !HAVE_NLA_NUL_STRING */
+
+#endif /* net/netlink.h */