Skip to content

Commit

Permalink
ofp-util: Fix uninitialized bytes in OF1.0 and OF1.1 table stats repl…
Browse files Browse the repository at this point in the history
…ies.

Also, use ovs_strlcpy() instead of strcpy() just to be a teensy bit safer.

Found by valgrind.

Bug #14357.
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Ethan Jackson <[email protected]>
  • Loading branch information
blp committed Jan 9, 2013
1 parent b0aa814 commit 3bdc692
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/ofp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3482,9 +3482,9 @@ ofputil_put_ofp10_table_stats(const struct ofp12_table_stats *in,
struct ofp10_table_stats *out;
const struct wc_map *p;

out = ofpbuf_put_uninit(buf, sizeof *out);
out = ofpbuf_put_zeros(buf, sizeof *out);
out->table_id = in->table_id;
strcpy(out->name, in->name);
ovs_strlcpy(out->name, in->name, sizeof out->name);
out->wildcards = 0;
for (p = wc_map; p < &wc_map[ARRAY_SIZE(wc_map)]; p++) {
if (in->wildcards & htonll(1ULL << p->mf12)) {
Expand Down Expand Up @@ -3542,9 +3542,9 @@ ofputil_put_ofp11_table_stats(const struct ofp12_table_stats *in,
{
struct ofp11_table_stats *out;

out = ofpbuf_put_uninit(buf, sizeof *out);
out = ofpbuf_put_zeros(buf, sizeof *out);
out->table_id = in->table_id;
strcpy(out->name, in->name);
ovs_strlcpy(out->name, in->name, sizeof out->name);
out->wildcards = oxm12_to_ofp11_flow_match_fields(in->wildcards);
out->match = oxm12_to_ofp11_flow_match_fields(in->match);
out->instructions = in->instructions;
Expand Down

0 comments on commit 3bdc692

Please sign in to comment.