From b592df89c1633ba5f478f7c54bded2f17ebdb483 Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Thu, 7 May 2026 19:45:37 +0300 Subject: [PATCH 1/3] Fix NULL deref in frogfs_get_entry on allocation failure frogfs_get_path() returns NULL when its calloc() fails, but frogfs_get_entry() passed the result directly to strcmp() without checking. gcc 15's -fanalyzer flags this as -Wanalyzer-null-argument. --- src/frogfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/frogfs.c b/src/frogfs.c index 3ee05f7..229aa80 100644 --- a/src/frogfs.c +++ b/src/frogfs.c @@ -191,6 +191,10 @@ const frogfs_entry_t *frogfs_get_entry(const frogfs_fs_t *fs, const char *path) do { entry = (const void *) fs->head + e->offs; char *match = frogfs_get_path(fs, entry); + if (!match) { + /* out of memory */ + return NULL; + } if (strcmp(path, match) == 0) { free(match); LOGV("entry %d", middle); From 162a1620c0f7e289cdb67aef0f83a0abd2cc09e8 Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Thu, 7 May 2026 20:29:41 +0300 Subject: [PATCH 2/3] Fix dh leak and possible NULL deref in frogfs_vfs_opendir frogfs_vfs_opendir() did not check the malloc result for dh, and also returned without freeing dh when frogfs_get_entry() failed. --- src/vfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vfs.c b/src/vfs.c index 2ea042e..04e63ba 100644 --- a/src/vfs.c +++ b/src/vfs.c @@ -187,9 +187,13 @@ static DIR* frogfs_vfs_opendir(void *ctx, const char *path) { frogfs_vfs_t *vfs = (frogfs_vfs_t *) ctx; frogfs_vfs_dh_t *dh = malloc(sizeof(*dh)); + if (!dh) { + return NULL; + } const frogfs_entry_t *entry = frogfs_get_entry(vfs->fs, path); if (entry == NULL) { + free(dh); return NULL; } From 0e636cbd590541fce426f35531bb8c02cb12257b Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Thu, 7 May 2026 20:30:20 +0300 Subject: [PATCH 3/3] Fix priv leak in open_miniz on unsupported gzip method open_miniz() returned -1 without freeing priv when the gzip compression method byte was not 8 (deflate). --- src/decomp_miniz.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/decomp_miniz.c b/src/decomp_miniz.c index 86f3e9f..d3784df 100644 --- a/src/decomp_miniz.c +++ b/src/decomp_miniz.c @@ -46,6 +46,7 @@ static int open_miniz(frogfs_fh_t *f, unsigned int flags) /* gzip */ if (*(p + 2) != 8) { LOGE("unsupported gzip compression method"); + free(priv); return -1; } priv->data += 10;