зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
ced2d699b0
Коммит
a0eeef69e7
|
@ -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.
|
||||
|
|
13
dln_find.c
13
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();
|
||||
|
|
Загрузка…
Ссылка в новой задаче