Sophie

Sophie

distrib > Mandriva > current > i586 > media > contrib-release-src > by-pkgid > 9b19196514d6aa0d1d802274c3abf2f5 > files > 7

Mowitz-0.3.0-8mdv2008.1.src.rpm

--- Mowitz/MwFilesel.c.ori	2007-08-28 21:55:34.000000000 +0200
+++ Mowitz/MwFilesel.c	2007-08-28 21:59:07.000000000 +0200
@@ -80,7 +80,7 @@
 {
 	DIR *dird;
 	struct dirent *dire;
-	char fn[1024];
+	char fn[PATH_MAX];
 	struct stat buf;
 	char **ldir = NULL, **lfile = NULL;
 	int ndir = 0, mdir = 0, nfile = 0, mfile = 0;
@@ -90,7 +90,10 @@
 		return 1;
 	}
 	while ((dire = readdir(dird))) {
-		sprintf(fn, "%s/%s", path, dire->d_name);
+		if (snprintf(fn, PATH_MAX, "%s/%s", path, dire->d_name) >= PATH_MAX) {
+			fprintf(stderr, "Path too long %s/%s\n", path, dire->d_name);
+			continue;
+		}
 		if ((stat(fn, &buf))) {
 			fprintf(stderr, "Can't stat %s\n", fn);
 			continue;