2003-06-03  Roland McGrath  <roland@redhat.com>

	* strace.c (main): In PATH search, accept only a regular file with
	execute bits set.  Fixes Debian bug #137103.
diff --git a/strace.c b/strace.c
index 368eb86..5f1d155 100644
--- a/strace.c
+++ b/strace.c
@@ -439,7 +439,12 @@
 				if (len && pathname[len - 1] != '/')
 					pathname[len++] = '/';
 				strcpy(pathname + len, filename);
-				if (stat(pathname, &statbuf) == 0)
+				if (stat(pathname, &statbuf) == 0 &&
+				    /* Accept only regular files
+				       with some execute bits set.
+				       XXX not perfect, might still fail */
+				    S_ISREG(statbuf.st_mode) &&
+				    (statbuf.st_mode & 0111))
 					break;
 			}
 		}