Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 2edc406

Browse files
committed
Fix the sysctl json parsing
1 token shift during the token reading like this: file: ```{"hostname":"951d97892fdb","containers":[{"id":"951d97892fdbde41341606127fba406788a39117f36da61048a92350566cab2d","rootfs":"/rootfs","fstype":"ext4","imag e":"sda","addr":"0:0","fsmap":[{"source":"rLfDEQDukA","path":"/dev/termination-log","readOnly":false,"dockerVolume":true},{"source":"ZuaaEsQpWD","path":"/etc/hosts","readOnly":false,"dockerVolume":true}],"sysctl":{"vm.overcommit_memory":" 1"},"process":{"terminal":false,"stdio":1,"stderr":2,"args":["sh"],"envs":[{"env":"PATH","value":"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}],"workdir":"/"},"restartPolicy":"never","initialize":false}],"interfaces":[{" device":"eth0","ipAddress":"172.16.1.227","netMask":"255.255.0.0"}],"dns":["172.16.0.2","8.8.8.8"],"routes":[{"dest":"0.0.0.0/0","gateway":"172.16.0.1","device":"eth0"}],"shareDir":"share_dir","portmappingWhiteLists":{"internalNetworks":[ "172.16.0.0/16"]}}``` ```I0208 03:13:11.761152 21073 init_comm.go:68] [console] 31 name sysctl I0208 03:13:11.761267 21073 init_comm.go:68] [console] sysctl size 1 I0208 03:13:11.761404 21073 init_comm.go:68] [console] sysctl 1:process``` Signed-off-by: Wang Xu <gnawux@gmail.com>
1 parent 9de9caf commit 2edc406

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/parse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,11 @@ static int container_parse_sysctl(struct hyper_container *c, char *json, jsmntok
465465

466466
i++;
467467
for (j = 0; j < c->sys_num; j++) {
468-
c->sys[j].path = (json_token_str(json, &toks[++i]));
468+
c->sys[j].path = (json_token_str(json, &toks[i++]));
469469
while((p = strchr(c->sys[j].path, '.')) != NULL) {
470470
*p = '/';
471471
}
472-
c->sys[j].value = (json_token_str(json, &toks[++i]));
472+
c->sys[j].value = (json_token_str(json, &toks[i++]));
473473
dbg_pr(stdout, "sysctl %s:%s\n", c->sys[j].path, c->sys[j].value);
474474
}
475475
return i;

0 commit comments

Comments
 (0)