summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLili Huang <huanglili.huang@huawei.com>2017-11-29 15:24:05 +0800
committerBen Pfaff <blp@ovn.org>2017-11-29 08:37:52 -0800
commit7b398b07cd9884b06474f5bf2246eef22279852e (patch)
tree8a00a33dcd7a0e425dfbbf45f9c16b27b23cc5b7
parentbf7e459bf4d216678d2e68a607141eb62f5649af (diff)
downloadopenvswitch-7b398b07cd9884b06474f5bf2246eef22279852e.tar.gz
ovs-ofctl: Fix bad free in colors_parse_from_env().
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 <huanglili.huang@huawei.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mark Michelson <mmichels@redhat.com>
-rw-r--r--lib/colors.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/colors.c b/lib/colors.c
index 4ea1880d8..13456445e 100644
--- a/lib/colors.c
+++ b/lib/colors.c
@@ -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, ":")) {
@@ -134,5 +135,5 @@ colors_parse_from_env(const struct color_key color_dic[])
}
}
}
- free(s);
+ free(s_head);
}