On Wed, Feb 14, 2018 at 01:58:31AM -0800, Daniel Benli Ye wrote:
> From: Benli Ye <dani...@vmware.com>
> 
> As struct ipfix_data_record_flow_key_iface didn't calculate
> its length in flow key part, it may cause problem when flow
> key part length is not enough. Use MAX_IF_LEN and MAX_IF_DESCR
> to pre-allocate memory for ipfix_data_record_flow_key_iface.
> 
> Signed-off-by: Daniel Benli Ye <dani...@vmware.com>

Thanks for the patch.

It looks like this fixes commit cd32509e4af4, so I'd add the following
tags to the commit message (and I'm CCing Michal):

CC: Michal Weglicki <michalx.wegli...@intel.com>
Fixes: cd32509e4af4 ("ofproto-dpif-ipfix: add interface Information Elements to 
flow key")


> @@ -2030,9 +2045,11 @@ ipfix_get_iface_data_record(const struct dpif_ipfix 
> *di, odp_port_t port_no,
>  
>      smap_destroy(&netdev_status);
>      data->if_index = htonl(port->ifindex);
> -    data->if_descr_len = data->if_descr ? strlen(data->if_descr) : 0;
> +    data->if_descr_len = data->if_descr ? strlen(data->if_descr) > 
> MAX_IF_DESCR_LEN
> +                             ? MAX_IF_DESCR_LEN : strlen(data->if_descr) : 0;
>      data->if_name = nullable_xstrdup(netdev_get_name(port->ofport->netdev));
> -    data->if_name_len = data->if_name ? strlen(data->if_name) : 0;
> +    data->if_name_len = data->if_name ? strlen(data->if_name) > 
> MAX_IF_NAME_LEN
> +                            ? MAX_IF_NAME_LEN : strlen(data->if_name) : 0;

It's unusual and always a little confusing to see a ? b ? c : d : e.
I think that these can be rewritten using strnlen, e.g.:

data->if_descr ? strnlen(data->if_descr, MAX_IF_DESCR_LEN) : 0;

If you agree, would you mind posting v2?

Michal, any comments?

Thanks,

Ben.
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to