From 20f91672568b1d2e341a9bb0dba88a831f152f1c Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Mon, 4 Aug 2014 23:34:32 -0400 Subject: [PATCH] Fix glob memory leak in GSS initialization In loadConfigFiles, call globfree even if glob fails, since glob can allocate memory and report partial results on failure. Also initialize globbuf before calling glob; this is not strictly required, but hedges against hypothetical libc implementation bugs which could leave globbuf.gl_pathc or globbuf.gl_pathv uninitialized on error. ticket: 7981 --- src/lib/gssapi/mechglue/g_initialize.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/gssapi/mechglue/g_initialize.c b/src/lib/gssapi/mechglue/g_initialize.c index 85810a9c12..2987164edc 100644 --- a/src/lib/gssapi/mechglue/g_initialize.c +++ b/src/lib/gssapi/mechglue/g_initialize.c @@ -437,11 +437,12 @@ loadConfigFiles() load_if_changed(MECH_CONF, g_confFileModTime, &highest); + memset(&globbuf, 0, sizeof(globbuf)); if (glob(MECH_CONF_PATTERN, 0, NULL, &globbuf) == 0) { for (path = globbuf.gl_pathv; *path != NULL; path++) load_if_changed(*path, g_confFileModTime, &highest); - globfree(&globbuf); } + globfree(&globbuf); g_confFileModTime = highest; } -- 2.47.2