From 8210c254bee19294af67bcee0e8f5e02ebb39a60 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 5 Feb 2002 07:56:31 +0000 Subject: * 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 --- file.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'file.c') 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); -- cgit v1.2.3