summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-05 07:56:31 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-05 07:56:31 +0000
commit8210c254bee19294af67bcee0e8f5e02ebb39a60 (patch)
tree91734ef17b33d9f50435abec5286dca5492e17ec /file.c
parent49c720ff67cbca36cac3a6a4775c5522ea7d93b2 (diff)
* io.c (fptr_finalize): should raise error when fclose fails.
* eval.c (method_inspect): proper output format to distinguish methods and singleton methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/file.c b/file.c
index 96ecb7edf3..1eea9360e4 100644
--- a/file.c
+++ b/file.c
@@ -1459,8 +1459,9 @@ rb_file_s_expand_path(argc, argv)
if (!NIL_P(dname)) {
dname = rb_file_s_expand_path(1, &dname);
if (OBJ_TAINTED(dname)) tainted = 1;
- BUFCHECK (strlen(RSTRING(dname)->ptr) > buflen);
- strcpy(buf, RSTRING(dname)->ptr);
+ BUFCHECK (RSTRING(dname)->len > buflen);
+ memcpy(buf, RSTRING(dname)->ptr, RSTRING(dname)->len);
+ p += RSTRING(dname)->len;
}
else {
char *dir = my_getcwd();
@@ -1468,8 +1469,8 @@ rb_file_s_expand_path(argc, argv)
tainted = 1;
BUFCHECK (strlen(dir) > buflen);
strcpy(buf, dir);
+ p = &buf[strlen(buf)];
}
- p = &buf[strlen(buf)];
while (p > buf && *(p - 1) == '/') p--;
}
else {
@@ -1539,9 +1540,6 @@ rb_file_s_expand_path(argc, argv)
memcpy(++p, b, s-b);
p += s-b;
}
- else if (p == buf) {
- p++;
- }
#if defined(DOSISH)
else if (ISALPHA(buf[0]) && (buf[1] == ':') && isdirsep(buf[2])) {
/* root directory needs a trailing backslash,
@@ -1554,8 +1552,8 @@ rb_file_s_expand_path(argc, argv)
#endif
if (tainted) OBJ_TAINT(result);
- *p = '\0';
RSTRING(result)->len = p - buf;
+ *p = '\0';
return result;
}
@@ -2308,7 +2306,7 @@ path_check_1(path)
for (;;) {
if (stat(p0, &st) == 0 && (st.st_mode & 002)) {
if (p) *p = '/';
- rb_warn("Bad mode 0%o on %s", st.st_mode, p0);
+ rb_warn("Unsecure world writeable dir %s , mode 0%o", p0, st.st_mode);
return 0;
}
s = strrdirsep(p0);