Skip to content

Commit

Permalink
ovs-ofctl: Fix bad free in colors_parse_from_env().
Browse files Browse the repository at this point in the history
OVS_COLORS variable color_str is parsed by using xstrdup and strsep,
we should free original address of the string, not used after strsep.

Signed-off-by: Lili Huang <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Mark Michelson <[email protected]>
  • Loading branch information
h00277896 authored and blp committed Nov 29, 2017
1 parent bf7e459 commit 7b398b0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/colors.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ colors_parse_from_env(const struct color_key color_dic[])

/* Loop on tokens: they are separated by columns ':' */
char *s = xstrdup(color_str);
char *s_head = s;
for (char *token = strsep(&s, ":");
token != NULL;
token = strsep(&s, ":")) {
Expand All @@ -134,5 +135,5 @@ colors_parse_from_env(const struct color_key color_dic[])
}
}
}
free(s);
free(s_head);
}

0 comments on commit 7b398b0

Please sign in to comment.