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
This commit is contained in:
Philip Withnall 2017-09-11 09:23:17 +01:00
parent aa3e8ee097
commit 7069dc0261

View File

@ -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++;
}