diff options
author | Matthias Clasen <mclasen@redhat.com> | 2005-07-10 04:44:27 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2005-07-10 04:44:27 +0000 |
commit | 35425ca9d6be66a9484c853435df23c8ddb6547b (patch) | |
tree | 18af2868875cf937dcde9a721dca1b44ae22c913 /glib/gutils.c | |
parent | 3baeda095b2d810c2c96e59b46a2d35667caefdd (diff) | |
download | glib-35425ca9d6be66a9484c853435df23c8ddb6547b.tar.gz |
Ignore anomalous environment entries which are not of the form
2005-07-10 Matthias Clasen <mclasen@redhat.com>
* glib/gutils.c (g_listenv): Ignore anomalous environment
entries which are not of the form variable=value. (#309859,
Morten Welinder)
Diffstat (limited to 'glib/gutils.c')
-rw-r--r-- | glib/gutils.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/glib/gutils.c b/glib/gutils.c index ffa8968c1..e59f280a1 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -1341,18 +1341,20 @@ gchar ** g_listenv (void) { gchar **result, *eq; - gint len, i; + gint len, i, j; len = g_strv_length (environ); result = g_new0 (gchar *, len + 1); + j = 0; for (i = 0; i < len; i++) { eq = strchr (environ[i], '='); - result[i] = g_strndup (environ[i], eq - environ[i]); + if (eq) + result[j++] = g_strndup (environ[i], eq - environ[i]); } - result[len] = NULL; + result[j] = NULL; return result; } |