diff options
author | dzwdz | 2022-10-19 14:23:14 +0200 |
---|---|---|
committer | dzwdz | 2022-10-19 14:23:14 +0200 |
commit | 3655115e5a3c50fc06afd801100a9d75d813fd2b (patch) | |
tree | c9d4f39608d19d0a4b0b886d70d9b86463a59d60 /src/user/app | |
parent | 753d43d349bfde6b83cff650c9354c4a0442a3ae (diff) |
user/libc: BSD err.h, getprogname()
Diffstat (limited to 'src/user/app')
-rw-r--r-- | src/user/app/httpd/httpd.c | 9 |
1 files changed, 3 insertions, 6 deletions
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 <camellia/flags.h> #include <camellia/syscalls.h> +#include <err.h> #include <stdio.h> #include <string.h> #include <unistd.h> -#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); |