Skip to content

Commit

Permalink
ovsdb-idlc: Initialize nonnull string columns for inserted rows.
Browse files Browse the repository at this point in the history
When a schema column has type "exactly one string", the corresponding
struct member has type "char *" and the documented and expected behavior
is that the string should always be nonnull.  (The code generator even
adds a comment /* Always nonnull. */ in the struct definition.)  In the
case where a value is not available, the string is supposed to be
initialized to "" instead of to NULL.

However, the IDL code for inserting a new row did not properly initialize
the column to "", instead leaving it NULL.  This could cause null pointer
dereferences in corner cases.

This commit fixes the problem.

Reported-by: Lance Richardson <[email protected]>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2016-December/326500.html
Signed-off-by: Ben Pfaff <[email protected]>
Tested-by: Lance Richardson <[email protected]>
  • Loading branch information
blp committed Dec 21, 2016
1 parent d4f531c commit 5a98d74
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ovsdb/ovsdb-idlc.in
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ void
for columnName, column in sorted_columns(table):
if column.type.is_smap():
print " smap_init(&row->%s);" % columnName
elif (column.type.n_min == 1 and
column.type.n_max == 1 and
column.type.key.type == ovs.db.types.StringType and
not column.type.value):
print " row->%s = \"\";" % columnName
print "}"

# First, next functions.
Expand Down

0 comments on commit 5a98d74

Please sign in to comment.