Coverity flagged a potential null dereference of txnid
when calling raft_next_entry() in ovsdb_storage_read().

To prevent this, raft_next_entry() now checks whether txnid is non-NULL
before attempting to write to it. This preserves existing behavior
when txnid is valid, while safely handling the case where it is NULL.

No change to normal operation; this only prevents potential crashes
if a NULL txnid is passed.

Signed-off-by: Eelco Chaudron <echau...@redhat.com>
---
 ovsdb/raft.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ovsdb/raft.c b/ovsdb/raft.c
index 9694c94e6..32349c8af 100644
--- a/ovsdb/raft.c
+++ b/ovsdb/raft.c
@@ -3622,7 +3622,9 @@ raft_next_entry(struct raft *raft, struct uuid *eid)
     }
 
     raft->last_applied++;
-    *eid = e->eid;
+    if (eid) {
+        *eid = e->eid;
+    }
 
     /* DB will only read each entry once, so we don't need to store the fully
      * parsed json object any longer.  The serialized version is sufficient
-- 
2.50.1

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

Reply via email to