summaryrefslogtreecommitdiff
path: root/dln_find.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-24 23:42:01 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-24 23:42:01 (GMT)
commita0eeef69e79e4b1351a011cec56a9ae5c7d2bca8 (patch)
tree4447b78544e5a85263ffe4c1c96e66296dddda69 /dln_find.c
parentced2d699b05ae5557f075ab6c0fa8111a7526b6e (diff)
* dln_find.c (dln_find_1): omit too long pathnames.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dln_find.c')
-rw-r--r--dln_find.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/dln_find.c b/dln_find.c
index 2873152..347ef52 100644
--- a/dln_find.c
+++ b/dln_find.c
@@ -128,7 +128,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
register const char *ep;
register char *bp;
struct stat st;
- size_t i, fspace;
+ size_t i, fnlen, fspace;
#ifdef DOSISH
static const char extension[][5] = {
EXECUTABLE_EXTS,
@@ -140,12 +140,17 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
const char *p = fname;
static const char pathname_too_long[] = "openpath: pathname too long (ignored)\n\
-\tDirectory \"%.*s\"\n\tFile \"%s\"\n";
-#define PATHNAME_TOO_LONG() fprintf(stderr, pathname_too_long, (int)(bp - fbuf), fbuf, fname)
+\tDirectory \"%.*s\"%s\n\tFile \"%.*s\"%s\n";
+#define PATHNAME_TOO_LONG() fprintf(stderr, pathname_too_long, \
+ ((bp - fbuf) > 100 ? 100 : (int)(bp - fbuf)), fbuf, \
+ ((bp - fbuf) > 100 ? "..." : ""), \
+ (fnlen > 100 ? 100 : (int)fnlen), fname, \
+ (fnlen > 100 ? "..." : ""))
#define RETURN_IF(expr) if (expr) return (char *)fname;
RETURN_IF(!fname);
+ fnlen = strlen(fname);
#ifdef DOSISH
# ifndef CharNext
# define CharNext(p) ((p)+1)
@@ -262,7 +267,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
}
/* now append the file name */
- i = strlen(fname);
+ i = fnlen;
if (fspace < i) {
toolong:
PATHNAME_TOO_LONG();