Fix the sdb shell malfunction in ASan build 41/89741/2
authorSlava Barinov <v.barinov@samsung.com>
Mon, 26 Sep 2016 15:06:29 +0000 (18:06 +0300)
committerSlava Barinov <v.barinov@samsung.com>
Wed, 28 Sep 2016 11:27:30 +0000 (14:27 +0300)
Accordingly to exec(3) manual the envp argument is an array of pointers to
null-terminated strings and must be terminated by a null pointer.

Without the terminator execvp fails and errno is set to 'Bad address'

Change-Id: I00e6927fd62323b7a9bea918cc79b0c4e02d77fd
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
src/services.c

index 2fbcaa797fe52798a7de63415a0bb951ee0549e3..c3f72c1531fe78ed4954860135d2cefc88ae225c 100644 (file)
@@ -653,6 +653,9 @@ static int create_subproc_thread(const char *name, int lines, int columns)
     }
     free(envp_plugin);
 
+    /* Last element of envp must be the NULL-terminator to prevent execvp fail */
+    envp[envp_cnt] = NULL;
+
     if(name) { // in case of shell execution directly
         // Check the shell command validation.
         if (!request_plugin_verification(SDBD_CMD_VERIFY_SHELLCMD, name)) {