[PATCH] Fix segfault when there's no config dir

Keith Packard keithp at keithp.com
Thu Dec 1 06:23:35 PST 2011


On Wed, 30 Nov 2011 14:16:33 -0200, Paulo Zanoni <przanoni at gmail.com> wrote:
> 2011/11/28 Keith Packard <keithp at keithp.com>:
> > On Mon, 28 Nov 2011 09:09:42 -0800, Jeremy Huddleston <jeremyhu at apple.com> wrote:
> >
> >> That seems like a second patch, independent of this one...
> >
> > No, if the scandir return value was error-checked, then num would always
> > be >= 0 and the existing code would work fine.
> 
> So, is this version ok? Do I need to do something else?  I received
> reports on IRC and we also have bug #43286 about it.

I was thinking of something that explicitly handled the scandir error
return case in the obvious way:

@@ -852,6 +852,10 @@ OpenConfigDir(const char *path, const char *cmdline, const char *projroot,
 
 		/* match files named *.conf */
 		num = scandir(dirpath, &list, ConfigFilter, alphasort);
+		if (num < 0) {
+			num = 0;
+			list = NULL;
+		}
 		found = AddConfigDirFiles(dirpath, list, num);
 		if (!found) {
 			free(dirpath);

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20111201/c0f51538/attachment.pgp>


More information about the xorg-devel mailing list