From 37c4b2967863fe5ba265a7fefad60dbd96a09f17 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Thu, 13 Jun 2024 08:25:29 +0200 Subject: auth.c: Reject empty files It makes no sense to attempt to fopen(3) an empty file and malloc(3) zero bytes so as to dump it, as dump_db is still meant to fail on empty files. --- auth.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/auth.c b/auth.c index 1db2683..e642ccd 100644 --- a/auth.c +++ b/auth.c @@ -35,6 +35,11 @@ static char *dump_db(const char *const path) fprintf(stderr, "%s: stat(2): %s\n", __func__, strerror(errno)); goto end; } + else if (!sb.st_size) + { + fprintf(stderr, "%s: %s is empty\n", __func__, path); + goto end; + } else if (sb.st_size > SIZE_MAX - 1) { fprintf(stderr, "%s: %s too big (%llu bytes, %zu max)\n", -- cgit v1.2.3