[gtk+] gtkmountoperation-x11: Do array length check before dereference



commit 7069dc0261ffe96c6c6ac3959481529228eec5f5
Author: Philip Withnall <withnall endlessm com>
Date:   Mon Sep 11 09:23:17 2017 +0100

    gtkmountoperation-x11: Do array length check before dereference
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=787302

 gtk/gtkmountoperation-x11.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkmountoperation-x11.c b/gtk/gtkmountoperation-x11.c
index 10c7bbc..adb47b1 100644
--- a/gtk/gtkmountoperation-x11.c
+++ b/gtk/gtkmountoperation-x11.c
@@ -653,7 +653,7 @@ pid_get_env (GPid         pid,
       n = 0;
       while (TRUE)
         {
-          if (env[n] == '\0' || n >= env_len)
+          if (n >= env_len || env[n] == '\0')
             break;
 
           if (g_str_has_prefix (env + n, key) && (*(env + n + key_len) == '='))
@@ -666,7 +666,7 @@ pid_get_env (GPid         pid,
               break;
             }
 
-          for (; env[n] != '\0' && n < env_len; n++)
+          for (; n < env_len && env[n] != '\0'; n++)
             ;
           n++;
         }


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