From 3655115e5a3c50fc06afd801100a9d75d813fd2b Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 19 Oct 2022 14:23:14 +0200 Subject: user/libc: BSD err.h, getprogname() --- src/user/app/httpd/httpd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/user/app/httpd/httpd.c') diff --git a/src/user/app/httpd/httpd.c b/src/user/app/httpd/httpd.c index 2ffc2ba..02f9e6b 100644 --- a/src/user/app/httpd/httpd.c +++ b/src/user/app/httpd/httpd.c @@ -2,12 +2,11 @@ * easily DoSable (like the rest of the network stack), vulnerable to path traversal, etc */ #include #include +#include #include #include #include -#define eprintf(fmt, ...) fprintf(stderr, "httpd: "fmt"\n" __VA_OPT__(,) __VA_ARGS__) - static void handle(FILE *c) { char buf[2048]; fgets(buf, sizeof buf, c); @@ -69,10 +68,8 @@ int main(int argc, char **argv) { handle_t conn; for (;;) { conn = _syscall_open(path, strlen(path), OPEN_RW); - if (conn < 0) { - eprintf("open('%s') failed, %d", path, conn); - return 1; - } + if (conn < 0) + errx(1, "open('%s') failed, errno %d", path, -conn); FILE *f = fdopen(conn, "a+"); handle(f); fclose(f); -- cgit v1.2.3