From: James Jones Date: Sat, 23 Jul 2022 11:48:31 +0000 (-0500) Subject: Check strrchr() return in link_fixup() (CID #1504305) (#4627) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cbc3cdb41c1055041aa170bb8e873383b1aca28b;p=thirdparty%2Ffreeradius-server.git Check strrchr() return in link_fixup() (CID #1504305) (#4627) --- diff --git a/scripts/jlibtool.c b/scripts/jlibtool.c index c4a7e9e9681..6a8dff74d6c 100644 --- a/scripts/jlibtool.c +++ b/scripts/jlibtool.c @@ -2399,6 +2399,7 @@ static void link_fixup(command_t *cmd) { char *tmp = lt_malloc(PATH_MAX + 30); + char *suffix; if (cmd->install_path) { strcpy(tmp, cmd->install_path); @@ -2406,11 +2407,14 @@ static void link_fixup(command_t *cmd) strcpy(tmp, ""); } - if (cmd->shared_name.install) { - strcat(tmp, strrchr(cmd->shared_name.install, '/')); - } else { - strcat(tmp, strrchr(cmd->shared_name.normal, '/')); + suffix = strrchr((cmd->shared_name.install ? + cmd->shared_name.install : cmd->shared_name.normal), + '/'); + if (!suffix) { + ERROR("Installation mode requires directory\n"); + exit(1); } + strcat(tmp, suffix); /* * Add the version as "libfoo.so.PROGRAM_VERSION"