summaryrefslogtreecommitdiff
path: root/ovsdb
diff options
context:
space:
mode:
authorDumitru Ceara <dceara@redhat.com>2022-01-24 15:17:28 +0100
committerIlya Maximets <i.maximets@ovn.org>2022-02-14 22:35:42 +0100
commit8ed26a8be3bef2a7c880da8f13aba249b67761aa (patch)
treec97bc15b0b89a32ae550e97c6c25c0a07f44b0a9 /ovsdb
parent989895501c53468569064e060f15bba3fc8f0cac (diff)
downloadopenvswitch-8ed26a8be3bef2a7c880da8f13aba249b67761aa.tar.gz
treewide: Don't pass NULL to library functions that expect non-NULL.
It's actually undefined behavior to pass NULL to standard library functions that manipulate arrays (e.g., qsort, memcpy, memcmp), even if the passed number of items is 0. UB Sanitizer reports: ovsdb/monitor.c:408:9: runtime error: null pointer passed as argument 1, which is declared to never be null #0 0x406ae1 in ovsdb_monitor_columns_sort ovsdb/monitor.c:408 #1 0x406ae1 in ovsdb_monitor_add ovsdb/monitor.c:1683 [...] lib/ovsdb-data.c:1970:5: runtime error: null pointer passed as argument 2, which is declared to never be null #0 0x4071c8 in ovsdb_datum_push_unsafe lib/ovsdb-data.c:1970 #1 0x471cd0 in ovsdb_datum_apply_diff_in_place lib/ovsdb-data.c:2345 [...] ofproto/ofproto-dpif-rid.c:159:17: runtime error: null pointer passed as argument 1, which is declared to never be null #0 0x4df5d8 in frozen_state_equal ofproto/ofproto-dpif-rid.c:159 #1 0x4dfd27 in recirc_find_equal ofproto/ofproto-dpif-rid.c:179 [...] Acked-by: Aaron Conole <aconole@redhat.com> Signed-off-by: Dumitru Ceara <dceara@redhat.com> Acked-by: Paolo Valerio <pvalerio@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'ovsdb')
-rw-r--r--ovsdb/monitor.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ovsdb/monitor.c b/ovsdb/monitor.c
index ab814cf20..0f222cc99 100644
--- a/ovsdb/monitor.c
+++ b/ovsdb/monitor.c
@@ -405,6 +405,10 @@ ovsdb_monitor_columns_sort(struct ovsdb_monitor *dbmon)
SHASH_FOR_EACH (node, &dbmon->tables) {
struct ovsdb_monitor_table *mt = node->data;
+ if (mt->n_columns == 0) {
+ continue;
+ }
+
qsort(mt->columns, mt->n_columns, sizeof *mt->columns,
compare_ovsdb_monitor_column);
for (i = 0; i < mt->n_columns; i++) {