summaryrefslogtreecommitdiff
path: root/src/lib/eo/eo.c
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-06-21 13:10:56 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2018-06-21 17:11:40 +0200
commitdc2aa79843f0e127a04eb54dbcf0340908acefb1 (patch)
treefaed974ecfd2237590de11b8f5824f48c9d4fd3f /src/lib/eo/eo.c
parent6c0af430cc3373651f301adbc951844fc62eb7cc (diff)
eo_debug: Fix segfault when parsing EO_LIFECYCLE_DEBUG envvar
Summary: The 'if' block should only be executed when the string contains the colon and something else behind, but sscanf cannot be used in this case. If the string contained no colon, the following line with strchr(s, ':') returns NULL and everything explodes. Test Plan: eo_debug -l now works for me without segfaulting. Reviewers: bu5hm4n, zmike, devilhorns, q66 Subscribers: cedric, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D6347
Diffstat (limited to 'src/lib/eo/eo.c')
-rw-r--r--src/lib/eo/eo.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 3799378..63cb2a2 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -3135,10 +3135,10 @@ _eo_log_obj_init(void)
3135 s = getenv("EO_LIFECYCLE_DEBUG"); 3135 s = getenv("EO_LIFECYCLE_DEBUG");
3136 if ((s) && (s[0] != '\0')) 3136 if ((s) && (s[0] != '\0'))
3137 { 3137 {
3138 int lvl = 1; 3138 char *es;
3139 3139 int lvl = (int)strtol(s, &es, 10);
3140 _eo_log_objs_level = EO_REF_OP_FREE; 3140 _eo_log_objs_level = EO_REF_OP_FREE;
3141 if (sscanf(s, "%d:%*s", &lvl) == 1) 3141 if ((es != s) && (*es == ':'))
3142 { 3142 {
3143 if (lvl >= 3) 3143 if (lvl >= 3)
3144 { 3144 {
@@ -3152,7 +3152,7 @@ _eo_log_obj_init(void)
3152 EINA_LOG_DOM_DBG(_eo_log_objs_dom, 3152 EINA_LOG_DOM_DBG(_eo_log_objs_dom,
3153 "will log new, free, ref and unref"); 3153 "will log new, free, ref and unref");
3154 } 3154 }
3155 s = strchr(s, ':') + 1; 3155 s = es + 1;
3156 } 3156 }
3157 3157
3158 if ((strcmp(s, "*") == 0) || (strcmp(s, "1") == 0)) 3158 if ((strcmp(s, "*") == 0) || (strcmp(s, "1") == 0))