Commit 01e71ec6 authored by Richard Genoud's avatar Richard Genoud Committed by Tom Rini
Browse files

fs/squashfs: sqfs_search_dir: fix dangling pointer



dirs->entry shouldn't be left dangling as it could be freed twice.
Signed-off-by: default avatarRichard Genoud <richard.genoud@posteo.net>
parent 7d23b2c5
...@@ -485,6 +485,7 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list, ...@@ -485,6 +485,7 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
if (!ret) if (!ret)
break; break;
free(dirs->entry); free(dirs->entry);
dirs->entry = NULL;
} }
if (ret) { if (ret) {
...@@ -530,6 +531,7 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list, ...@@ -530,6 +531,7 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
if (ret) if (ret)
return -EINVAL; return -EINVAL;
free(dirs->entry); free(dirs->entry);
dirs->entry = NULL;
ret = sqfs_search_dir(dirs, sym_tokens, token_count, ret = sqfs_search_dir(dirs, sym_tokens, token_count,
m_list, m_count); m_list, m_count);
...@@ -537,6 +539,7 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list, ...@@ -537,6 +539,7 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
} else if (!sqfs_is_dir(get_unaligned_le16(&dir->inode_type))) { } else if (!sqfs_is_dir(get_unaligned_le16(&dir->inode_type))) {
printf("** Cannot find directory. **\n"); printf("** Cannot find directory. **\n");
free(dirs->entry); free(dirs->entry);
dirs->entry = NULL;
return -EINVAL; return -EINVAL;
} }
...@@ -556,6 +559,7 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list, ...@@ -556,6 +559,7 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
if (sqfs_is_empty_dir(table)) { if (sqfs_is_empty_dir(table)) {
printf("Empty directory.\n"); printf("Empty directory.\n");
free(dirs->entry); free(dirs->entry);
dirs->entry = NULL;
return SQFS_EMPTY_DIR; return SQFS_EMPTY_DIR;
} }
...@@ -564,6 +568,7 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list, ...@@ -564,6 +568,7 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
dirs->entry_count = dirs->dir_header->count + 1; dirs->entry_count = dirs->dir_header->count + 1;
dirs->size -= SQFS_DIR_HEADER_SIZE; dirs->size -= SQFS_DIR_HEADER_SIZE;
free(dirs->entry); free(dirs->entry);
dirs->entry = NULL;
} }
offset = sqfs_dir_offset(table, m_list, m_count); offset = sqfs_dir_offset(table, m_list, m_count);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment