commit 02284f43106857f9dc41578d6d3d72c75bc7fc14
parent 7ae5e798d6f9d96de928370a1e7b6fdb0b03d394
Author: Nick Mathewson <nickm@torproject.org>
Date: Mon, 28 Apr 2025 12:29:05 -0400
Avoid crash on failure to read FamilyKeyDir
Previously we could try to iterate over `files`
even if it were NULL.
Fixes bug #41043; bugfix on 0.4.9.2-alpha.
Diffstat:
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/changes/bug41043 b/changes/bug41043
@@ -0,0 +1,3 @@
+ o Minor bugfixes (relay):
+ - Fix a crash when FamilyKeyDir is a path that cannot be read.
+ Fixes bug 41043; bugfix on 0.4.9.2-alpha.
diff --git a/src/feature/relay/routerkeys.c b/src/feature/relay/routerkeys.c
@@ -761,8 +761,10 @@ list_family_key_files_impl(const char *keydir)
SMARTLIST_FOREACH(result, char *, cp, tor_free(cp));
smartlist_free(result); // sets result to NULL.
done:
- SMARTLIST_FOREACH(files, char *, cp, tor_free(cp));
- smartlist_free(files);
+ if (files) {
+ SMARTLIST_FOREACH(files, char *, cp, tor_free(cp));
+ smartlist_free(files);
+ }
return result;
}