Skip to content

Commit

Permalink
lib/odp-util: Do not use mask if it doesn't exist.
Browse files Browse the repository at this point in the history
Diagnostic code path dereferenced a NULL pointer.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Reviewed-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
  • Loading branch information
Jarno Rajahalme committed Apr 14, 2014
1 parent ca3d034 commit 5469535
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/odp-util.c
Expand Up @@ -1009,22 +1009,22 @@ format_odp_key_attr(const struct nlattr *a, const struct nlattr *ma,
expected_len = odp_flow_key_attr_len(nl_attr_type(a));
if (expected_len != -2) {
bool bad_key_len = nl_attr_get_size(a) != expected_len;
bool bad_mask_len = ma && nl_attr_get_size(a) != expected_len;
bool bad_mask_len = ma && nl_attr_get_size(ma) != expected_len;

if (bad_key_len || bad_mask_len) {
if (bad_key_len) {
ds_put_format(ds, "(bad key length %"PRIuSIZE", expected %d)(",
nl_attr_get_size(a),
odp_flow_key_attr_len(nl_attr_type(a)));
nl_attr_get_size(a), expected_len);
}
format_generic_odp_key(a, ds);
if (bad_mask_len) {
if (ma) {
ds_put_char(ds, '/');
ds_put_format(ds, "(bad mask length %"PRIuSIZE", expected %d)(",
nl_attr_get_size(ma),
odp_flow_key_attr_len(nl_attr_type(ma)));
if (bad_mask_len) {
ds_put_format(ds, "(bad mask length %"PRIuSIZE", expected %d)(",
nl_attr_get_size(ma), expected_len);
}
format_generic_odp_key(ma, ds);
}
format_generic_odp_key(ma, ds);
ds_put_char(ds, ')');
return;
}
Expand Down

0 comments on commit 5469535

Please sign in to comment.