Permalink
Browse files

* 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
  • Loading branch information...
1 parent ced2d69 commit a0eeef69e79e4b1351a011cec56a9ae5c7d2bca8 @nobu nobu committed Jan 24, 2011
Showing with 13 additions and 4 deletions.
  1. +4 −0 ChangeLog
  2. +9 −4 dln_find.c
View
@@ -1,3 +1,7 @@
+Tue Jan 25 08:41:58 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * dln_find.c (dln_find_1): omit too long pathnames.
+
Tue Jan 25 08:28:19 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_resize): get rid of out-of-bound access.
View
@@ -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();

0 comments on commit a0eeef6

Please sign in to comment.