1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* dln.c (dln_find_1): compare fspace in size_t world.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-03-13 12:00:04 +00:00
parent d202fd4f97
commit d5a60df399
2 changed files with 10 additions and 3 deletions

View file

@ -1,3 +1,7 @@
Fri Mar 13 20:58:11 2009 Tanaka Akira <akr@fsij.org>
* dln.c (dln_find_1): compare fspace in size_t world.
Fri Mar 13 18:58:04 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (CFLAGS, CXXFLAGS): moved after warnflags.

9
dln.c
View file

@ -1616,8 +1616,9 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
home = getenv("HOME");
if (home != NULL) {
i = strlen(home);
if ((fspace -= i) < 0)
if (fspace < i)
goto toolong;
fspace -= i;
memcpy(bp, home, i);
bp += i;
}
@ -1625,8 +1626,9 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
l--;
}
if (l > 0) {
if ((fspace -= l) < 0)
if (fspace < l)
goto toolong;
fspace -= l;
memcpy(bp, dp, l);
bp += l;
}
@ -1638,7 +1640,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
/* now append the file name */
i = strlen(fname);
if ((fspace -= i) < 0) {
if (fspace < i) {
toolong:
fprintf(stderr, "openpath: pathname too long (ignored)\n");
*bp = '\0';
@ -1646,6 +1648,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
fprintf(stderr, "\tFile \"%s\"\n", fname);
goto next;
}
fspace -= i;
memcpy(bp, fname, i + 1);
#if defined(DOSISH)