commit 51481e41cb6a7dd60783601c33aa4c13a95f0253 parent 831b8da1ebf3eabcae4c9cea8a72daf19aaeed25 Author: Ricardo Mones <ricardo@mones.org> Date: Fri, 9 Sep 2016 21:27:35 +0200 Fix potential out-of-bounds read Diffstat:
| M | src/plugins/archive/libarchive_archive.c | | | 14 | +++----------- |
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/src/plugins/archive/libarchive_archive.c b/src/plugins/archive/libarchive_archive.c @@ -284,18 +284,10 @@ static void archive_add_to_list(struct file_info* file) { } static gchar* strip_leading_dot_slash(gchar* path) { - gchar* stripped = path; - gchar* result = NULL; + if (path && strlen(path) > 1 && path[0] == '.' && path[1] == '/') + return g_strdup(&(path[2])); - if (stripped && stripped[0] == '.') { - ++stripped; - if (stripped && stripped[0] == '/') - ++stripped; - result = g_strdup(stripped); - } - else - result = g_strdup(path); - return result; + return g_strdup(path); } static gchar* get_full_path(struct file_info* file) {