aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2024-06-13 08:25:29 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2024-06-13 08:25:29 +0200
commit37c4b2967863fe5ba265a7fefad60dbd96a09f17 (patch)
tree2ef1a7846a59e2cb06c75a4140f3c77d3be69f2c
parent2d6fc0f9a6a60bc96ef9c4a10e450ed6a8247435 (diff)
downloadslcl-37c4b2967863fe5ba265a7fefad60dbd96a09f17.tar.gz
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.
-rw-r--r--auth.c5
1 files changed, 5 insertions, 0 deletions
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",