(extfs_open_archive): fix NULL dereferences.

Fix passing NULL pointer "tmp" to g_strconcat().

Found by Coverity.
Coverity is #331840.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2021-05-28 11:08:52 +03:00
parent 6efddd7380
commit 0df10f488b
1 changed files with 17 additions and 8 deletions

View File

@ -515,12 +515,13 @@ extfs_open_archive (int fstype, const char *name, struct extfs_super_t **pparc,
static dev_t archive_counter = 0;
mc_pipe_t *result = NULL;
mode_t mode;
char *cmd;
char *cmd = NULL;
struct stat mystat;
struct extfs_super_t *current_archive;
struct vfs_s_entry *root_entry;
char *tmp = NULL;
vfs_path_t *local_name_vpath = NULL;
const char *local_last_path = NULL;
vfs_path_t *name_vpath;
memset (&mystat, 0, sizeof (mystat));
@ -540,16 +541,24 @@ extfs_open_archive (int fstype, const char *name, struct extfs_super_t **pparc,
goto ret;
}
tmp = name_quote (vfs_path_get_last_path_str (name_vpath), FALSE);
local_last_path = vfs_path_get_last_path_str (local_name_vpath);
if (local_last_path == NULL)
tmp = name_quote (vfs_path_get_last_path_str (name_vpath), FALSE);
}
cmd = g_strconcat (info->path, info->prefix, " list ",
vfs_path_get_last_path_str (local_name_vpath) != NULL ?
vfs_path_get_last_path_str (local_name_vpath) : tmp, (char *) NULL);
g_free (tmp);
if (local_last_path != NULL)
cmd = g_strconcat (info->path, info->prefix, " list ", local_last_path, (char *) NULL);
else if (tmp != NULL)
{
cmd = g_strconcat (info->path, info->prefix, " list ", tmp, (char *) NULL);
g_free (tmp);
}
result = mc_popen (cmd, TRUE, TRUE, error);
g_free (cmd);
if (cmd != NULL)
{
result = mc_popen (cmd, TRUE, TRUE, error);
g_free (cmd);
}
if (result == NULL)
{