From 8867e00eec23df35ab960f7290a193490c588de3 Mon Sep 17 00:00:00 2001 From: "shingil.kang" Date: Wed, 2 Mar 2016 17:49:28 +0900 Subject: [PATCH] Fixed segment fault error on arch64 Change-Id: Idbc8006317e121ebd884642a06c3cd03a9811b63 Signed-off-by: shingil.kang --- packaging/sdbd.spec | 2 +- src/services.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 4294dc8..dc6d083 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -2,7 +2,7 @@ Name: sdbd Summary: SDB daemon -Version: 3.0.2 +Version: 3.0.3 Release: 0 License: Apache-2.0 Summary: SDB daemon diff --git a/src/services.c b/src/services.c index e845e4f..f5c62f3 100644 --- a/src/services.c +++ b/src/services.c @@ -529,6 +529,7 @@ static void get_env(char *key, char **env) s = buf; e = buf + (strlen(buf) - 1); + // trim string while(*e == ' ' || *e == '\n' || *e == '\t') { e--; } @@ -538,6 +539,7 @@ static void get_env(char *key, char **env) s++; } + // skip comment or null string if (*s == '#' || *s == '\0') { continue; } @@ -545,7 +547,7 @@ static void get_env(char *key, char **env) *value++ = '\0'; if(!strcmp(buf, key)) { - *env = value; + *env = strdup(value); break; } } @@ -596,8 +598,10 @@ static int create_subproc_thread(const char *name, int lines, int columns) envp[3] = path; free(trim_value); } else { - envp[3] = value; + snprintf(path, sizeof(path), "%s", value); + envp[3] = path; } + free(value); } D("path env:%s,%s,%s,%s\n", envp[0], envp[1], envp[2], envp[3]); -- 2.34.1