diff options
author | William Tu <u9012063@gmail.com> | 2020-05-15 06:46:55 -0700 |
---|---|---|
committer | William Tu <u9012063@gmail.com> | 2020-05-20 08:49:27 -0700 |
commit | 68bc6f88a3a36549fcd3b6248c25c5e2e6deb8f3 (patch) | |
tree | 625caaf43c99604992175f5fbf51d593e7df0dc2 /lib/ovsdb-idl.c | |
parent | c6e9348ed488ea88d8945b96d35433093d2b835a (diff) | |
download | openvswitch-68bc6f88a3a36549fcd3b6248c25c5e2e6deb8f3.tar.gz |
ovsdb-idl: Fix NULL deref reported by Coverity.
When 'datum.values' or 'datum.keys' is NULL, some code path calling
into ovsdb_idl_txn_write__ triggers NULL deref.
An example:
ovsrec_open_vswitch_set_cur_cfg(const struct ovsrec_open_vswitch
{
struct ovsdb_datum datum;
union ovsdb_atom key;
datum.n = 1;
datum.keys = &key;
key.integer = cur_cfg;
// 1. assign_zero: Assigning: datum.values = NULL.
datum.values = NULL;
// CID 1421356 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)
// 2. var_deref_model: Passing &datum to ovsdb_idl_txn_write_clone,\
// which dereferences null datum.values.
ovsdb_idl_txn_write_clone(&row->header_, &ovsrec_open_vswitch_col
}
And with the following calls:
ovsdb_idl_txn_write_clone
ovsdb_idl_txn_write__
6. deref_parm_in_call: Function ovsdb_datum_destroy dereferences
datum->values
ovsdb_datum_destroy
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: William Tu <u9012063@gmail.com>
Diffstat (limited to 'lib/ovsdb-idl.c')
-rw-r--r-- | lib/ovsdb-idl.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index 1535ad7b5..6614ea161 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -4449,7 +4449,8 @@ ovsdb_idl_txn_write__(const struct ovsdb_idl_row *row_, * transaction only does writes of existing values, without making any real * changes, we will drop the whole transaction later in * ovsdb_idl_txn_commit().) */ - if (write_only && ovsdb_datum_equals(ovsdb_idl_read(row, column), + if (datum->keys && datum->values && + write_only && ovsdb_datum_equals(ovsdb_idl_read(row, column), datum, &column->type)) { goto discard_datum; } |