[PATCH] fix off-by-one in rtnl_act_parse()

Cong Wang xiyou.wangcong at gmail.com
Fri Mar 28 20:28:24 EDT 2014


On Fri, Mar 28, 2014 at 6:17 AM, Thomas Haller <thaller at redhat.com> wrote:
> Hi,
>
> Cong, why do you think that libnl should shift the index "i" by one?
> Sorry, I just don't see it :)
>
>
> kernel also uses similar loops:
>
> $ git grep -n for.*TCA_ACT_MAX_PRIO
> net/sched/act_api.c:593: for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
> net/sched/act_api.c:871: for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {

I had the same conclusion until I saw a crash. ;)

For some reason I don't know,  the message dumped by kernel uses 0..MAX-1,
while the message to create new action uses 1..MAX. It is indeed weird for me
too.



More information about the libnl mailing list