2008-09-18 10:25:02 +00:00
|
|
|
diff -up kbd-1.12/src/findfile.c.dir kbd-1.12/src/findfile.c
|
2008-02-22 09:58:17 +00:00
|
|
|
--- kbd-1.12/src/findfile.c.dir 2004-01-16 20:45:31.000000000 +0100
|
2008-09-18 10:25:02 +00:00
|
|
|
+++ kbd-1.12/src/findfile.c 2008-09-18 12:21:17.000000000 +0200
|
|
|
|
@@ -92,6 +92,7 @@ findfile_in_dir(char *fnam, char *dir, i
|
2008-02-22 09:58:17 +00:00
|
|
|
if (d == NULL)
|
|
|
|
return NULL;
|
|
|
|
while ((de = readdir(d)) != NULL) {
|
|
|
|
+ struct stat statbuf;
|
|
|
|
int okdir;
|
|
|
|
|
|
|
|
if (strcmp(de->d_name, ".") == 0 ||
|
2008-09-18 10:25:02 +00:00
|
|
|
@@ -104,7 +105,6 @@ findfile_in_dir(char *fnam, char *dir, i
|
2008-02-22 09:58:17 +00:00
|
|
|
okdir = (ff && strcmp(de->d_name, fdir) == 0);
|
|
|
|
|
|
|
|
if ((secondpass && recdepth) || okdir) {
|
|
|
|
- struct stat statbuf;
|
|
|
|
char *a;
|
|
|
|
|
|
|
|
a = xmalloc(strlen(dir) + strlen(de->d_name) + 2);
|
2008-09-18 10:25:02 +00:00
|
|
|
@@ -136,6 +136,8 @@ findfile_in_dir(char *fnam, char *dir, i
|
2008-02-22 09:58:17 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
sprintf(pathname, "%s/%s", dir, de->d_name);
|
|
|
|
+ if (stat(pathname, &statbuf) != 0 || !S_ISREG(statbuf.st_mode))
|
|
|
|
+ continue;
|
|
|
|
|
|
|
|
/* Does tail consist of a known suffix and possibly
|
|
|
|
a compression suffix? */
|
2008-09-18 10:25:02 +00:00
|
|
|
@@ -180,13 +182,16 @@ FILE *findfile(char *fnam, char **dirpat
|
2008-02-22 09:58:17 +00:00
|
|
|
/* Test for full pathname - opening it failed, so need suffix */
|
|
|
|
/* (This is just nonsense, for backwards compatibility.) */
|
|
|
|
if (*fnam == '/') {
|
|
|
|
+ struct stat statbuf;
|
|
|
|
+
|
|
|
|
for (sp = suffixes; *sp; sp++) {
|
|
|
|
if (strlen(fnam) + strlen(*sp) + 1 > sizeof(pathname))
|
|
|
|
continue;
|
|
|
|
if (*sp == 0)
|
|
|
|
continue; /* we tried it already */
|
|
|
|
sprintf(pathname, "%s%s", fnam, *sp);
|
|
|
|
- if((fp = fopen(pathname, "r")) != NULL)
|
|
|
|
+ if(stat(pathname, &statbuf) == 0 && S_ISREG(statbuf.st_mode)
|
|
|
|
+ && (fp = fopen(pathname, "r")) != NULL)
|
|
|
|
return fp;
|
|
|
|
}
|
|
|
|
|
2008-09-18 10:25:02 +00:00
|
|
|
@@ -196,7 +201,9 @@ FILE *findfile(char *fnam, char **dirpat
|
2008-02-22 09:58:17 +00:00
|
|
|
+ strlen(dc->ext) + 1 > sizeof(pathname))
|
|
|
|
continue;
|
|
|
|
sprintf(pathname, "%s%s%s", fnam, *sp, dc->ext);
|
|
|
|
- if ((fp = fopen(pathname, "r")) != NULL) {
|
|
|
|
+ if (stat(pathname, &statbuf) == 0
|
|
|
|
+ && S_ISREG(statbuf.st_mode)
|
|
|
|
+ && (fp = fopen(pathname, "r")) != NULL) {
|
|
|
|
fclose(fp);
|
|
|
|
return pipe_open(dc);
|
|
|
|
}
|