--- 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;