user: remove static from idx vars, it causes crash after many iterations of nsjail 2.0
authorRobert Swiecki <robert@swiecki.net>
Mon, 16 Oct 2017 13:19:07 +0000 (15:19 +0200)
committerRobert Swiecki <robert@swiecki.net>
Mon, 16 Oct 2017 13:19:07 +0000 (15:19 +0200)
nsjail.c
user.c

index ca57367752bbd9b5f1694252cb1b2315f01b7cd2..80428aa1050a56b9f5d40c977441b369941b6e8a 100644 (file)
--- a/nsjail.c
+++ b/nsjail.c
@@ -101,8 +101,8 @@ static bool nsjailSetTimer(struct nsjconf_t* nsjconf)
        }
 
        struct itimerval it = {
-               .it_value = {.tv_sec = 1, .tv_usec = 0 },
-               .it_interval = {.tv_sec = 1, .tv_usec = 0 },
+               .it_value = { .tv_sec = 1, .tv_usec = 0 },
+               .it_interval = { .tv_sec = 1, .tv_usec = 0 },
        };
        if (setitimer(ITIMER_REAL, &it, NULL) == -1) {
                PLOG_E("setitimer(ITIMER_REAL)");
diff --git a/user.c b/user.c
index 9f5815a2a92796e538f270f1fc8dc8e1eb35e74f..63cc684c5c167110efc1517ae0825759fc150d5a 100644 (file)
--- a/user.c
+++ b/user.c
@@ -65,7 +65,7 @@ static bool userUidMapSelf(struct nsjconf_t* nsjconf, pid_t pid)
        char fname[PATH_MAX];
        snprintf(fname, sizeof(fname), "/proc/%d/uid_map", pid);
 
-       char map[4096] = {[0] = '\0' };
+       char map[4096] = { [0] = '\0' };
 
        struct idmap_t* p;
        TAILQ_FOREACH(p, &nsjconf->uids, pointers)
@@ -95,7 +95,7 @@ static bool userGidMapSelf(struct nsjconf_t* nsjconf, pid_t pid)
        char fname[PATH_MAX];
        snprintf(fname, sizeof(fname), "/proc/%d/gid_map", pid);
 
-       char map[4096] = {[0] = '\0' };
+       char map[4096] = { [0] = '\0' };
 
        struct idmap_t* p;
        TAILQ_FOREACH(p, &nsjconf->gids, pointers)
@@ -123,7 +123,7 @@ static bool userGidMapSelf(struct nsjconf_t* nsjconf, pid_t pid)
 /* Use /usr/bin/newgidmap for writing the gid map */
 static bool userGidMapExternal(struct nsjconf_t* nsjconf, pid_t pid UNUSED)
 {
-       static size_t idx = 0;
+       size_t idx = 0;
 
        const char* argv[1024];
        char parms[1024][256];
@@ -177,7 +177,7 @@ static bool userGidMapExternal(struct nsjconf_t* nsjconf, pid_t pid UNUSED)
 /* Use /usr/bin/newuidmap for writing the uid map */
 static bool userUidMapExternal(struct nsjconf_t* nsjconf, pid_t pid UNUSED)
 {
-       static size_t idx = 0;
+       size_t idx = 0;
 
        const char* argv[1024];
        char parms[1024][256];