]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Check strrchr() return in link_fixup() (CID #1504305) (#4627)
authorJames Jones <jejones3141@gmail.com>
Sat, 23 Jul 2022 11:48:31 +0000 (06:48 -0500)
committerGitHub <noreply@github.com>
Sat, 23 Jul 2022 11:48:31 +0000 (18:48 +0700)
scripts/jlibtool.c

index c4a7e9e968132a9db21e41b9091989885aacc87f..6a8dff74d6ca83a01d2c277d229b8539405198b9 100644 (file)
@@ -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"