Skip to content

Commit

Permalink
* dln_find.c (dln_find_1): omit too long pathnames.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Jan 24, 2011
1 parent ced2d69 commit a0eeef6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Tue Jan 25 08:41:58 2011 Nobuyoshi Nakada <[email protected]>

* dln_find.c (dln_find_1): omit too long pathnames.

Tue Jan 25 08:28:19 2011 Nobuyoshi Nakada <[email protected]>

* string.c (rb_str_resize): get rid of out-of-bound access.
Expand Down
13 changes: 9 additions & 4 deletions dln_find.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit a0eeef6

Please sign in to comment.