[glib: 6/7] gio: fix OOB string access if filename is empty




commit 0f85eefb8b3601d2b5d23b36c09a0184f6b18d94
Author: Marc-André Lureau <marcandre lureau redhat com>
Date:   Wed Feb 16 18:50:17 2022 +0400

    gio: fix OOB string access if filename is empty
    
    Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>

 gio/gcontenttype.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gio/gcontenttype.c b/gio/gcontenttype.c
index 3e5b841ab..3c9522bc6 100644
--- a/gio/gcontenttype.c
+++ b/gio/gcontenttype.c
@@ -780,7 +780,7 @@ g_content_type_guess (const gchar  *filename,
   if (filename)
     {
       i = strlen (filename);
-      if (filename[i - 1] == '/')
+      if (i > 0 && filename[i - 1] == '/')
         {
           name_mimetypes[0] = "inode/directory";
           name_mimetypes[1] = NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]