[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20140401.152606.1113760851598806005.davem@davemloft.net>
Date: Tue, 01 Apr 2014 15:26:06 -0400 (EDT)
From: David Miller <davem@...emloft.net>
To: pablo@...filter.org
Cc: netdev@...r.kernel.org, fw@...len.de, tgraf@...g.ch
Subject: Re: [PATCH v2] netlink: don't compare the nul-termination in
nla_strcmp
From: Pablo Neira Ayuso <pablo@...filter.org>
Date: Tue, 1 Apr 2014 19:38:44 +0200
> From: Pablo Neira <pablo@...filter.org>
>
> nla_strcmp compares the string length plus one, so it's implicitly
> including the nul-termination in the comparison.
>
> int nla_strcmp(const struct nlattr *nla, const char *str)
> {
> int len = strlen(str) + 1;
> ...
> d = memcmp(nla_data(nla), str, len);
>
> However, if NLA_STRING is used, userspace can send us a string without
> the nul-termination. This is a problem since the string
> comparison will not match as the last byte may be not the
> nul-termination.
>
> Fix this by skipping the comparison of the nul-termination if the
> attribute data is nul-terminated. Suggested by Thomas Graf.
>
> Cc: Florian Westphal <fw@...len.de>
> Cc: Thomas Graf <tgraf@...g.ch>
> Signed-off-by: Pablo Neira Ayuso <pablo@...filter.org>
Applied and queued up for -stable, thanks Pablo.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists