Commit 311d2538 authored by Jamal Hadi Salim's avatar Jamal Hadi Salim Committed by Jeff Garzik

[SCH_GRED]: Array overflow fixes, found by Stanford checker.

parent 39d712cc
...@@ -328,18 +328,20 @@ static int gred_change(struct Qdisc *sch, struct rtattr *opt) ...@@ -328,18 +328,20 @@ static int gred_change(struct Qdisc *sch, struct rtattr *opt)
struct tc_gred_qopt *ctl; struct tc_gred_qopt *ctl;
struct tc_gred_sopt *sopt; struct tc_gred_sopt *sopt;
struct rtattr *tb[TCA_GRED_STAB]; struct rtattr *tb[TCA_GRED_STAB];
struct rtattr *tb2[TCA_GRED_STAB]; struct rtattr *tb2[TCA_GRED_DPS];
int i; int i;
if (opt == NULL || if (opt == NULL ||
rtattr_parse(tb, TCA_GRED_STAB, RTA_DATA(opt), RTA_PAYLOAD(opt)) ) rtattr_parse(tb, TCA_GRED_STAB, RTA_DATA(opt), RTA_PAYLOAD(opt)) )
return -EINVAL; return -EINVAL;
if (tb[TCA_GRED_PARMS-1] == 0 && tb[TCA_GRED_STAB-1] == 0 && if (tb[TCA_GRED_PARMS-1] == 0 && tb[TCA_GRED_STAB-1] == 0) {
tb[TCA_GRED_DPS-1] != 0) {
rtattr_parse(tb2, TCA_GRED_DPS, RTA_DATA(opt), rtattr_parse(tb2, TCA_GRED_DPS, RTA_DATA(opt),
RTA_PAYLOAD(opt)); RTA_PAYLOAD(opt));
if (tb2[TCA_GRED_DPS-1] == 0)
return -EINVAL;
sopt = RTA_DATA(tb2[TCA_GRED_DPS-1]); sopt = RTA_DATA(tb2[TCA_GRED_DPS-1]);
table->DPs=sopt->DPs; table->DPs=sopt->DPs;
table->def=sopt->def_DP; table->def=sopt->def_DP;
...@@ -471,16 +473,18 @@ static int gred_init(struct Qdisc *sch, struct rtattr *opt) ...@@ -471,16 +473,18 @@ static int gred_init(struct Qdisc *sch, struct rtattr *opt)
struct gred_sched *table = (struct gred_sched *)sch->data; struct gred_sched *table = (struct gred_sched *)sch->data;
struct tc_gred_sopt *sopt; struct tc_gred_sopt *sopt;
struct rtattr *tb[TCA_GRED_STAB]; struct rtattr *tb[TCA_GRED_STAB];
struct rtattr *tb2[TCA_GRED_STAB]; struct rtattr *tb2[TCA_GRED_DPS];
if (opt == NULL || if (opt == NULL ||
rtattr_parse(tb, TCA_GRED_STAB, RTA_DATA(opt), RTA_PAYLOAD(opt)) ) rtattr_parse(tb, TCA_GRED_STAB, RTA_DATA(opt), RTA_PAYLOAD(opt)) )
return -EINVAL; return -EINVAL;
if (tb[TCA_GRED_PARMS-1] == 0 && tb[TCA_GRED_STAB-1] == 0 && if (tb[TCA_GRED_PARMS-1] == 0 && tb[TCA_GRED_STAB-1] == 0) {
tb[TCA_GRED_DPS-1] != 0) {
rtattr_parse(tb2, TCA_GRED_DPS, RTA_DATA(opt),RTA_PAYLOAD(opt)); rtattr_parse(tb2, TCA_GRED_DPS, RTA_DATA(opt),RTA_PAYLOAD(opt));
if (tb2[TCA_GRED_DPS-1] == 0)
return -EINVAL;
sopt = RTA_DATA(tb2[TCA_GRED_DPS-1]); sopt = RTA_DATA(tb2[TCA_GRED_DPS-1]);
table->DPs=sopt->DPs; table->DPs=sopt->DPs;
table->def=sopt->def_DP; table->def=sopt->def_DP;
......
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