Skip to content
Snippets Groups Projects
Commit a8a87b81 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

fix stack allocation, do some check

parent e5f0f338
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ parse_clean_list.o
parse_clean_quotes.o
parse_clean_runas.o
parse_compute_list.o
parse_compute_resolve.o
parse_contents.o
parse_dependencies.o
parse_error.o
......
......@@ -27,14 +27,15 @@
#include <66/service.h>
/**
* @opts -> 1 : build list of optional deps
* @opts -> 1 : build list removing commented optional deps
* */
int parse_compute_list(resolve_wrapper_t_ref wres, stralloc *sa, uint32_t *res, uint8_t opts)
{
int r, found = 0 ;
size_t len = sa->len, pos = 0 ;
char t[len + 1] ;
char f[len + 1] ;
size_t nelement = sastr_nelement(sa) ;
char t[len + nelement + 2] ;
char f[len + nelement + 2] ;
memset(f, 0, len) ;
memset(t, 0, len) ;
......
......@@ -44,7 +44,7 @@ int parse_dependencies(resolve_service_t *res, resolve_service_t *ares, unsigned
goto freed ;
}
char t[sa.len] ;
char t[sa.len + 1] ;
sastr_to_char(t, &sa) ;
......@@ -53,8 +53,8 @@ int parse_dependencies(resolve_service_t *res, resolve_service_t *ares, unsigned
for (; pos < len ; pos += strlen(t + pos) + 1) {
sa.len = 0 ;
char name[strlen(t + pos)] ;
char ainsta[strlen(t + pos)] ;
char name[strlen(t + pos) + 1] ;
char ainsta[strlen(t + pos) + 1] ;
int insta = -1 ;
log_trace("parse dependencies: ", t + pos, " of service: ", res->sa.s + res->name) ;
......
......@@ -21,6 +21,7 @@
#include <oblibs/mill.h>
#include <skalibs/stralloc.h>
#include <skalibs/types.h> //UINT_FMT
#include <66/parser.h>
#include <66/resolve.h>
......@@ -44,7 +45,7 @@ int parse_split_from_section(resolve_service_t *res, stralloc *secname, char *st
{
log_flow() ;
int e = 0, r = 0, found = 0, skip = 0 ;
int e = 0, r = 0, found = 0 ;
key_all_t const *list = total_list ;
stralloc sakey = STRALLOC_ZERO ;
......@@ -52,7 +53,7 @@ int parse_split_from_section(resolve_service_t *res, stralloc *secname, char *st
// cpos -> current, ipos -> idx pos, tpos -> temporary pos, end -> end the parse process
size_t len = strlen(str), cpos = 0, ipos = 0, tpos = 0, end = 0 ;
char tline[len + 1] ;
char store[len + 1] ;
char store[len + UINT_FMT + 1] ; // +6 be paranoid
char *line ;
// find the name of the current section
......@@ -85,7 +86,6 @@ int parse_split_from_section(resolve_service_t *res, stralloc *secname, char *st
while(cpos < len) {
skip = 0 ;
ipos = 0 ;
tpos = 0 ;
end = 0 ;
......
......@@ -25,8 +25,6 @@
#include <66/utils.h>
#include <66/environ.h>
#include <stdio.h>
int parse_store_environ(resolve_service_t *res, char *store, int idsec, int idkey)
{
int e = 0 ;
......
......@@ -47,6 +47,8 @@ int parse_store_logger(resolve_service_t *res, char *store, int idsec, int idkey
case KEY_LOGGER_SHEBANG:
log_1_warn("deprecated key @shebang -- define your complete shebang directly inside your @execute key field") ;
if (!parse_store_start_stop(res, store, idsec, KEY_STARTSTOP_SHEBANG))
goto err ;
......@@ -97,6 +99,9 @@ int parse_store_logger(resolve_service_t *res, char *store, int idsec, int idkey
if (!uint320_scan(store, &res->logger.maxsize))
parse_error_return(0, 3, idsec, idkey) ;
if (res->logger.maxsize < 4096 || res->logger.maxsize > 268435455)
parse_error_return(0, 0, idsec, idkey) ;
break ;
case KEY_LOGGER_TIMESTP:
......
......@@ -73,6 +73,10 @@ int parse_store_main(resolve_service_t *res, char *store, int idsec, int idkey)
case KEY_MAIN_TYPE:
if (res->name)
/** already passed through here */
break ;
if (!parse_clean_line(store))
parse_error_return(0, 8, idsec, idkey) ;
......@@ -108,6 +112,9 @@ int parse_store_main(resolve_service_t *res, char *store, int idsec, int idkey)
if (!uint320_scan(store, &res->maxdeath))
parse_error_return(0, 3, idsec, idkey) ;
if (res->maxdeath > 4096)
parse_error_return(0, 0, idsec, idkey) ;
break ;
case KEY_MAIN_FLAGS:
......@@ -278,6 +285,12 @@ int parse_store_main(resolve_service_t *res, char *store, int idsec, int idkey)
if (pos == (size_t)p) {
if (!owner)
/** avoid field e.g root root where originaly
* we want e.g. user root. The term user will be
* root at getpwuid() call */
continue ;
struct passwd *pw = getpwuid(owner);
if (!pw) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment