From d6eb807878922b2976831236c3f6235ccfb6edb4 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 26 Jan 2011 23:22:54 +0000 Subject: [PATCH] * dln_find.c (dln_find_1): use rb_warning and return immediately if fname is longer than buffer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ dln_find.c | 21 ++++++++++++++++----- version.h | 4 ++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index fd85383d62..659fd2e816 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jan 27 08:22:49 2011 Nobuyoshi Nakada + + * dln_find.c (dln_find_1): use rb_warning and return immediately + if fname is longer than buffer. + Wed Jan 26 22:57:30 2011 CHIKANAGA Tomoyuki * class.c (clone_method): add GC guard to prevent intermediate diff --git a/dln_find.c b/dln_find.c index 347ef52dc7..7ce3a957ed 100644 --- a/dln_find.c +++ b/dln_find.c @@ -15,10 +15,14 @@ #define dln_memerror rb_memerror #define dln_exit rb_exit #define dln_loaderror rb_loaderror +#define dln_warning rb_warning +#define dln_warning_arg #else #define dln_notimplement --->>> dln not implemented <<<--- #define dln_memerror abort #define dln_exit exit +#define dln_warning fprintf +#define dln_warning_arg stderr, static void dln_loaderror(const char *format, ...); #endif #include "dln.h" @@ -141,16 +145,23 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size, static const char pathname_too_long[] = "openpath: pathname too long (ignored)\n\ \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 PATHNAME_TOO_LONG() dln_warning(dln_warning_arg 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); + if (fnlen >= size) { + dln_warning(dln_warning_arg + "openpath: pathname too long (ignored)\n\tFile \"%.*s\"%s\n", + (fnlen > 100 ? 100 : (int)fnlen), fname, + (fnlen > 100 ? "..." : "")); + return NULL; + } #ifdef DOSISH # ifndef CharNext # define CharNext(p) ((p)+1) diff --git a/version.h b/version.h index 975eb9dfbe..f9a9cee9e0 100644 --- a/version.h +++ b/version.h @@ -1,11 +1,11 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_RELEASE_DATE "2011-01-26" +#define RUBY_RELEASE_DATE "2011-01-27" #define RUBY_PATCHLEVEL -1 #define RUBY_BRANCH_NAME "trunk" #define RUBY_RELEASE_YEAR 2011 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 26 +#define RUBY_RELEASE_DAY 27 #include "ruby/version.h"