diff options
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/db.h | 13 | ||||
-rw-r--r-- | src/server/s6-rcd.h | 1 | ||||
-rw-r--r-- | src/server/state.c | 20 | ||||
-rw-r--r-- | src/server/state.h | 3 |
4 files changed, 19 insertions, 18 deletions
diff --git a/src/server/db.h b/src/server/db.h deleted file mode 100644 index 2c960bc..0000000 --- a/src/server/db.h +++ /dev/null @@ -1,13 +0,0 @@ -/* ISC license. */ - -#ifndef S6RCD_DB_H -#define S6RCD_DB_H - -#include <s6-rc/db.h> - - /* Service database */ - -extern int db_load (s6rc_db_t *, char const *) ; -extern int db_read_sizes (s6rc_db_sizes_t *, char const *) ; - -#endif diff --git a/src/server/s6-rcd.h b/src/server/s6-rcd.h index ca0867a..ce47e0b 100644 --- a/src/server/s6-rcd.h +++ b/src/server/s6-rcd.h @@ -6,7 +6,6 @@ #include "client.h" #include "clientrules.h" #include "command.h" -#include "db.h" #include "dynstorage.h" #include "ep.h" #include "ev.h" diff --git a/src/server/state.c b/src/server/state.c index c6fb2d0..29d1548 100644 --- a/src/server/state.c +++ b/src/server/state.c @@ -4,16 +4,19 @@ #include <string.h> #include <stdlib.h> #include <stdio.h> +#include <errno.h> #include <skalibs/alloc.h> #include <skalibs/genalloc.h> #include <skalibs/buffer.h> #include <skalibs/djbunix.h> -#include <s6-rc/db.h> +#include "db.h" #include "dynstorage.h" #include "state.h" +#include <skalibs/posixishard.h> + static stateatom_t const stateatom_zero = STATEATOM_ZERO ; void instance_free (instance_t *ins) @@ -154,6 +157,7 @@ int state_read (char const *file, state_t *st, uint32_t const *dbn) char pack[4] ; if (buffer_get(&b, pack, 4) < 4) goto err ; uint32_unpack_big(pack, &n) ; + if (n > S6RC_INSTANCES_MAX) goto eproto ; if (!genalloc_ready(instance_t, st->dyn[type] + i, n)) goto err ; for (uint32_t j = 0 ; i < n ; j++) { @@ -162,10 +166,11 @@ int state_read (char const *file, state_t *st, uint32_t const *dbn) if (!atom_read(&b, &ins->state)) goto err ; if (buffer_get(&b, pack, 4) < 4) goto err ; uint32_unpack_big(pack, &len) ; + if (len > S6RC_INSTANCE_MAXLEN) goto eproto ; { char param[len + 1] ; if (buffer_get(&b, param, len + 1) < len + 1) goto err ; - if (param[len]) { errno = EINVAL ; goto err ; } + if (param[len]) goto eproto ; ins->param = dynstorage_add(param) ; if (!ins_param) goto err ; } @@ -173,9 +178,20 @@ int state_read (char const *file, state_t *st, uint32_t const *dbn) genalloc_setlen(instance_t, st->dyn[type] + i, n) ; } + { + char c ; + switch (buffer_get(&b, &c, 1)) + { + case -1 : goto err ; + case 1 : goto eproto ; + } + } + fd_close(fd) ; return 1 ; + eproto: + errno = EPROTO ; err: fd_close(fd) ; err0: diff --git a/src/server/state.h b/src/server/state.h index f49ffb4..2690f45 100644 --- a/src/server/state.h +++ b/src/server/state.h @@ -5,8 +5,7 @@ #include <skalibs/genalloc.h> -#include <s6-rc/db.h> - +#include "db.h" /* Service states, instances, machine state */ |