aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-09-01 18:30:17 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-09-05 18:37:25 +0200
commit4d5ce1b0b3b41b8fb53126a0c67534db7d010a75 (patch)
treeb504c18f1284a3281c74433c294d9182ac90992a
parent32fb61f039933a946067cff434e8a3386694a1d4 (diff)
Fix segmentation fault when random token
Change-Id: I98795f71dfab1fbc86d694d7ed357ae8387abd5d Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-session.c5
-rw-r--r--src/afb-session.h1
-rw-r--r--src/main.c6
3 files changed, 10 insertions, 2 deletions
diff --git a/src/afb-session.c b/src/afb-session.c
index d3e658dd..8b566838 100644
--- a/src/afb-session.c
+++ b/src/afb-session.c
@@ -135,6 +135,11 @@ void afb_session_init (int max_session_count, int timeout, const char *initok)
}
}
+const char *afb_session_initial_token()
+{
+ return sessions.initok;
+}
+
static struct afb_session *search (const char* uuid)
{
int idx;
diff --git a/src/afb-session.h b/src/afb-session.h
index e79d0376..ccedb4ab 100644
--- a/src/afb-session.h
+++ b/src/afb-session.h
@@ -20,6 +20,7 @@
struct afb_session;
extern void afb_session_init(int max_session_count, int timeout, const char *initok);
+extern const char *afb_session_initial_token();
extern struct afb_session *afb_session_create (const char *uuid, int timeout);
extern struct afb_session *afb_session_get (const char *uuid, int *created);
diff --git a/src/main.c b/src/main.c
index 91c7aae7..bffcb388 100644
--- a/src/main.c
+++ b/src/main.c
@@ -397,6 +397,7 @@ static int execute_command()
{
struct sigaction siga;
char port[20];
+ const char *token;
int rc;
/* check whether a command is to execute or not */
@@ -427,8 +428,9 @@ static int execute_command()
}
else {
/* instanciate arguments and environment */
- if (instanciate_command_args(port, config->token) >= 0
- && instanciate_environ(port, config->token) >= 0) {
+ token = afb_session_initial_token();
+ if (instanciate_command_args(port, token) >= 0
+ && instanciate_environ(port, token) >= 0) {
/* run */
if (!SELF_PGROUP)
setpgid(0, 0);