geomyidae

A small C-based gopherd. (gopher://bitreich.org/1/scm/geomyidae)
git clone git://r-36.net/geomyidae
Log | Files | Refs | README | LICENSE

commit b6cd8dc7652f6a9cc6e74bf24b0df27be2a47d32
parent 25298ac2cb69c28100c9cc5aa1fde245e23743f5
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat, 23 Jun 2018 11:32:25 +0200

fix promises buffer size and small cleanup

with feedback from quinq

Signed-off-by: Christoph Lohmann <20h@r-36.net>

Diffstat:
main.c | 20++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/main.c b/main.c @@ -539,11 +539,14 @@ main(int argc, char *argv[]) cltlen = sizeof(clt); #ifdef __OpenBSD__ - char promises[30]; - snprintf(promises, sizeof(promises), "rpath inet stdio proc exec %s %s", + char *promises = (char[35]){}; + snprintf(promises, 35, "rpath inet stdio proc exec %s %s", revlookup ? "dns" : "", dofork ? "tty" : ""); - pledge(promises, NULL); + if (pledge(promises, NULL) == -1) { + perror("pledge"); + exit(1); + } #endif /* __OpenBSD__ */ while (1) { @@ -585,11 +588,12 @@ main(int argc, char *argv[]) signal(SIGALRM, SIG_DFL); #ifdef __OpenBSD__ - char client_promises[25]; - snprintf(client_promises, sizeof(client_promises), - "rpath inet stdio %s", - nocgi ? "" : "proc exec" ); - pledge(client_promises, NULL); + promises = nocgi ? "rpath inet stdio" : + "rpath inet stdio proc exec"; + if (pledge(promises, NULL) == -1) { + perror("pledge"); + exit(1); + } #endif /* __OpenBSD__ */ handlerequest(sock, base, ohost, sport, clienth,