From: Ben Pfaff Date: Mon, 10 May 2010 20:53:26 +0000 (-0700) Subject: datapath: Avoid possibility of negative 'n_flows' in struct odp_flowvec. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d7568dc38fb832b7e152c184b0bdfdca6bb9527;p=openvswitch datapath: Avoid possibility of negative 'n_flows' in struct odp_flowvec. do_flowvec_ioctl() was checking for too-big 'n_flows' but not negative 'n_flows'. We could add that check too, but 'n_flows' should never be negative so it's better to just use an unsigned type. --- diff --git a/datapath/datapath.c b/datapath/datapath.c index 79a1f632..eec998ca 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -1143,7 +1143,8 @@ error: static int query_flows(struct datapath *dp, const struct odp_flowvec *flowvec) { struct tbl *table = rcu_dereference(dp->table); - int i; + u32 i; + for (i = 0; i < flowvec->n_flows; i++) { struct __user odp_flow *ufp = &flowvec->flows[i]; struct odp_flow uf; @@ -1167,8 +1168,8 @@ static int query_flows(struct datapath *dp, const struct odp_flowvec *flowvec) struct list_flows_cbdata { struct odp_flow __user *uflows; - int n_flows; - int listed_flows; + u32 n_flows; + u32 listed_flows; }; static int list_flow(struct tbl_node *node, void *cbdata_) diff --git a/include/openvswitch/datapath-protocol.h b/include/openvswitch/datapath-protocol.h index 94723ef0..1c2dba9b 100644 --- a/include/openvswitch/datapath-protocol.h +++ b/include/openvswitch/datapath-protocol.h @@ -242,7 +242,7 @@ struct odp_flow_put { struct odp_flowvec { struct odp_flow *flows; - int n_flows; + __u32 n_flows; }; /* The VLAN id is 12 bits, so we can use the entire 16 bits to indicate