This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[COMMITTED PATCH] Don't crash in iconv setup when getcwd fails.


When __getcwd fails, __gconv_get_path will call strlen on a null pointer.
This fix at least delays the crash until the cwd is actually needed (if it
ever is).  This makes some iconv/ tests work in a circumstance where getcwd
fails.


Thanks,
Roland


2015-02-25  Roland McGrath  <roland@hack.frob.com>

	* iconv/gconv_conf.c (__gconv_get_path): Don't crash if __getcwd
	returns a null pointer.

--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -468,7 +468,7 @@ __gconv_get_path (void)
 				":", 1),
 		     default_gconv_path, sizeof (default_gconv_path));
 	  cwd = __getcwd (NULL, 0);
-	  cwdlen = strlen (cwd);
+	  cwdlen = __glibc_unlikely (cwd == NULL) ? 0 : strlen (cwd);
 	}
       assert (default_gconv_path[0] == '/');
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]