From: Nick Mathewson Date: Mon, 28 Apr 2025 16:29:05 +0000 (-0400) Subject: Avoid crash on failure to read FamilyKeyDir X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02284f43106857f9dc41578d6d3d72c75bc7fc14;p=thirdparty%2Ftor.git 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. --- diff --git a/changes/bug41043 b/changes/bug41043 new file mode 100644 index 0000000000..f0c28927da --- /dev/null +++ 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 index 9f956ee6b4..31a57b75bf 100644 --- 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; }