diff options
author | Liran Schour <lirans@il.ibm.com> | 2016-08-16 09:06:58 +0300 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2016-08-26 09:31:54 -0700 |
commit | 4bb7f5680b19f6ffc1d7fc1d29959af1529a1318 (patch) | |
tree | 5b7b3370a545e063d6e47c3860f7377c4076991a /python | |
parent | f850c889d9e74e4e190b5bbc50a33658798a04ec (diff) | |
download | openvswitch-4bb7f5680b19f6ffc1d7fc1d29959af1529a1318.tar.gz |
ovsdb: Fix reference to table's row on condition_add|remove_clause
Use struct uuid * on [add|remove]_clause on columns which are references to
tables. That prevents use-after-free errors.
Signed-off-by: Liran Schour <lirans@il.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/ovs/db/types.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/python/ovs/db/types.py b/python/ovs/db/types.py index 944372ee2..a87c83c0e 100644 --- a/python/ovs/db/types.py +++ b/python/ovs/db/types.py @@ -339,8 +339,11 @@ class BaseType(object): return english - def toCType(self, prefix): + def toCType(self, prefix, refTable=True): if self.ref_table_name: + if not refTable: + assert self.type == UuidType + return 'struct uuid *' return "struct %s%s *" % (prefix, self.ref_table_name.lower()) else: return {IntegerType: 'int64_t ', @@ -352,18 +355,22 @@ class BaseType(object): def toAtomicType(self): return "OVSDB_TYPE_%s" % self.type.to_string().upper() - def copyCValue(self, dst, src): + def copyCValue(self, dst, src, refTable=True): args = {'dst': dst, 'src': src} if self.ref_table_name: + if not refTable: + return "%(dst)s = *%(src)s;" % args return ("%(dst)s = %(src)s->header_.uuid;") % args elif self.type == StringType: return "%(dst)s = xstrdup(%(src)s);" % args else: return "%(dst)s = %(src)s;" % args - def assign_c_value_casting_away_const(self, dst, src): + def assign_c_value_casting_away_const(self, dst, src, refTable=True): args = {'dst': dst, 'src': src} if self.ref_table_name: + if not refTable: + return "%(dst)s = *%(src)s;" % args return ("%(dst)s = %(src)s->header_.uuid;") % args elif self.type == StringType: return "%(dst)s = CONST_CAST(char *, %(src)s);" % args |