diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-06-13 08:25:29 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-06-13 08:25:29 +0200 |
| commit | 37c4b2967863fe5ba265a7fefad60dbd96a09f17 (patch) | |
| tree | 2ef1a7846a59e2cb06c75a4140f3c77d3be69f2c | |
| parent | 2d6fc0f9a6a60bc96ef9c4a10e450ed6a8247435 (diff) | |
| download | slcl-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.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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", |
