summaryrefslogtreecommitdiff
path: root/dln_find.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-26 23:22:54 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-26 23:22:54 (GMT)
commitd6eb807878922b2976831236c3f6235ccfb6edb4 (patch)
tree2a846a26b262bc242b1b3bd183ece068c9f551b0 /dln_find.c
parentc8e5ba0e841e2629d282c5853fc334309f36293f (diff)
* 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
Diffstat (limited to 'dln_find.c')
-rw-r--r--dln_find.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/dln_find.c b/dln_find.c
index 347ef52..7ce3a95 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)