Fix potential out-of-bounds read
authorRicardo Mones <ricardo@mones.org>
Fri, 9 Sep 2016 19:27:35 +0000 (21:27 +0200)
committerRicardo Mones <ricardo@mones.org>
Fri, 9 Sep 2016 19:27:35 +0000 (21:27 +0200)
src/plugins/archive/libarchive_archive.c

index 5499d1e04f1a0d8da987be33804611f49719402f..018108b30ef66892a2156d74adfd8ffe7a929249 100644 (file)
@@ -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) {