diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-06-11 10:20:57 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-06-11 10:20:57 +0000 |
commit | 04025bdc6c15c307ffa4fbcf39eec39024b9b935 (patch) | |
tree | 7b8ef3976b28882a9071279f27f203d9e5b42925 /src/libs6rc/s6rc_db_read.c | |
parent | c1000a7cfdd12a686e3846f15dce81a5c5d79955 (diff) | |
download | s6-rc-04025bdc6c15c307ffa4fbcf39eec39024b9b935.tar.xz |
Fix totally buggy db->argvs management
Diffstat (limited to 'src/libs6rc/s6rc_db_read.c')
-rw-r--r-- | src/libs6rc/s6rc_db_read.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libs6rc/s6rc_db_read.c b/src/libs6rc/s6rc_db_read.c index f0c7909..f10462c 100644 --- a/src/libs6rc/s6rc_db_read.c +++ b/src/libs6rc/s6rc_db_read.c @@ -52,7 +52,7 @@ static inline int s6rc_db_read_services (buffer *b, s6rc_db_t *db) unsigned int n = db->nshort + db->nlong ; s6rc_service_t *sv = db->services ; unsigned int nargvs = db->nargvs ; - char **argvs = db->argvs ; + unsigned int argvpos = 0 ; char type ; #ifdef DEBUG register unsigned int i = 0 ; @@ -106,19 +106,19 @@ static inline int s6rc_db_read_services (buffer *b, s6rc_db_t *db) sv->type = 0 ; for (; i < 2 ; i++) { - uint32 argvpos, argc ; + uint32 pos, argc ; if (!s6rc_db_read_uint32(b, &argc)) return -1 ; DBG(" argc[%u] is %u, nargvs is %u", i, argc, nargvs) ; if (argc > nargvs) return 0 ; - if (!s6rc_db_read_uint32(b, &argvpos)) return -1 ; - DBG(" argvpos[%u] is %u", i, argvpos) ; - if (!s6rc_db_check_valid_strings(db->string, db->stringlen, argvpos, argc)) return 0 ; - if (!env_make((char const **)argvs, argc, db->string + argvpos, db->stringlen - argvpos)) return -1 ; - DBG(" first arg is %s", argvs[0]) ; + if (!s6rc_db_read_uint32(b, &pos)) return -1 ; + DBG(" pos[%u] is %u", i, pos) ; + if (!s6rc_db_check_valid_strings(db->string, db->stringlen, pos, argc)) return 0 ; + if (!env_make((char const **)db->argvs + argvpos, argc, db->string + pos, db->stringlen - pos)) return -1 ; + DBG(" first arg is %s", db->argvs[argvpos]) ; sv->x.oneshot.argv[i] = argvpos ; sv->x.oneshot.argc[i] = argc ; - argvs += argc ; nargvs -= argc ; - if (!nargvs--) return 0 ; *argvs++ = 0 ; + argvpos += argc ; nargvs -= argc ; + if (!nargvs--) return 0 ; db->argvs[argvpos++] = 0 ; } } if (buffer_get(b, &type, 1) < 1) return -1 ; |