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

* file.c (rb_file_chown): integer conversion should be prior to

GetOpenFile().  [ruby-dev:24947]

* file.c (rb_file_truncate): ditto.

* file.c (rb_file_s_truncate): ditto.

* dir.c (dir_seek): use NUM2OFFT().

* misc/ruby-mode.el (ruby-non-block-do-re): [ruby-core:03719]

* dir.c (dir_seek): should retrieve dir_data after NUM2INT().
  [ruby-dev:24941]

* string.c (rb_str_splice): should place index wrapping after
  possible modification.  [ruby-dev:24940]

* eval.c (error_print): nicer traceback at interrupt.
  [ruby-core:03774]

* string.c (str_gsub): internal buffer should not be listed by
  ObjectSpace.each_object() by String#gsub.  [ruby-dev:24931]

* lib/cgi/session.rb (CGI::Session::FileStore::initialize): raise
  exception if data corresponding to session specified from the
  client does not exist.

* string.c (str_gsub): internal buffer should not be listed by
  ObjectSpace.each_object().  [ruby-dev:24919]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-11-22 15:29:52 +00:00
parent e2242e7e2a
commit 39080991ab
11 changed files with 109 additions and 23 deletions

View file

@ -1,8 +1,26 @@
Tue Nov 23 00:10:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* file.c (rb_file_chown): integer conversion should be prior to
GetOpenFile(). [ruby-dev:24947]
* file.c (rb_file_truncate): ditto.
* file.c (rb_file_s_truncate): ditto.
* dir.c (dir_seek): use NUM2OFFT().
* misc/ruby-mode.el (ruby-non-block-do-re): [ruby-core:03719]
Mon Nov 22 22:33:02 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::parse_require): Don't use names
of variables or constants when oarsing 'require'
Mon Nov 22 00:13:35 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (dir_seek): should retrieve dir_data after NUM2INT().
[ruby-dev:24941]
Sat Nov 20 23:57:33 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/README (et al): Add a new directive, :section:, and
@ -16,12 +34,10 @@ Sat Nov 20 23:56:54 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/options.rb (Options::parse): Force --inline-source if
--one-file option given
Thu Nov 18 18:41:08 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
Sat Nov 20 23:55:19 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* test/ruby/test_stringchar.rb (test_bang): added.
* string.c (rb_str_upcase_bang, rb_str_capitalize_bang)
(rb_str_swapcase_bang): missing rb_str_modify(). [ruby-dev:24915]
* string.c (rb_str_splice): should place index wrapping after
possible modification. [ruby-dev:24940]
Tue Nov 20 13:26:03 2004 NARUSE, Yui <naruse@ruby-lang.org>
@ -33,6 +49,34 @@ Tue Nov 20 05:34:24 2004 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/test.rb: add test for mime encode/decode
Sat Nov 20 01:37:34 2004 Johan Holmberg <holmberg@iar.se>
* eval.c (error_print): nicer traceback at interrupt.
[ruby-core:03774]
Sat Nov 20 00:07:16 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (str_gsub): internal buffer should not be listed by
ObjectSpace.each_object() by String#gsub. [ruby-dev:24931]
Fri Nov 19 01:20:22 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/cgi/session.rb (CGI::Session::FileStore::initialize): raise
exception if data corresponding to session specified from the
client does not exist.
Fri Nov 19 00:59:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (str_gsub): internal buffer should not be listed by
ObjectSpace.each_object(). [ruby-dev:24919]
Thu Nov 18 18:41:08 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* test/ruby/test_stringchar.rb (test_bang): added.
* string.c (rb_str_upcase_bang, rb_str_capitalize_bang)
(rb_str_swapcase_bang): missing rb_str_modify(). [ruby-dev:24915]
Thu Nov 18 00:21:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* process.c (proc_getpgrp): prohibit for $SAFE=2.

View file

@ -530,6 +530,9 @@ else
AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>y) : (x)>>y))
fi
AC_CHECK_HEADERS(stdio_ext.h)
AC_CHECK_FUNCS(__fpending)
AC_MSG_CHECKING(read count field in FILE structures)
AC_CACHE_VAL(rb_cv_fcnt,
[for fcnt in dnl

5
dir.c
View file

@ -466,10 +466,11 @@ dir_seek(dir, pos)
VALUE dir, pos;
{
struct dir_data *dirp;
off_t p = NUM2OFFT(pos);
#ifdef HAVE_SEEKDIR
GetDIR(dir, dirp);
seekdir(dirp->dir, NUM2INT(pos));
#ifdef HAVE_SEEKDIR
seekdir(dirp->dir, p);
return dir;
#else
rb_notimplement();

1
eval.c
View file

@ -1146,6 +1146,7 @@ error_print()
if (elen == 0) {
warn_print(": ");
warn_print2(RSTRING(epath)->ptr, RSTRING(epath)->len);
warn_print("\n");
}
else {
char *tail = 0;

24
file.c
View file

@ -1744,15 +1744,18 @@ rb_file_chown(obj, owner, group)
VALUE obj, owner, group;
{
OpenFile *fptr;
int o, g;
rb_secure(2);
GetOpenFile(obj, fptr);
o = NUM2INT(owner);
g = NUM2INT(group);
#if defined(DJGPP) || defined(__CYGWIN32__) || defined(_WIN32) || defined(__EMX__)
if (!fptr->path) return Qnil;
if (chown(fptr->path, NUM2INT(owner), NUM2INT(group)) == -1)
if (chown(fptr->path, o, g) == -1)
rb_sys_fail(fptr->path);
#else
if (fchown(fileno(fptr->f), NUM2INT(owner), NUM2INT(group)) == -1)
if (fchown(fileno(fptr->f), o, g) == -1)
rb_sys_fail(fptr->path);
#endif
@ -2804,11 +2807,14 @@ static VALUE
rb_file_s_truncate(klass, path, len)
VALUE klass, path, len;
{
off_t pos;
rb_secure(2);
pos = NUM2OFFT(len);
SafeStringValue(path);
#ifdef HAVE_TRUNCATE
if (truncate(StringValueCStr(path), NUM2OFFT(len)) < 0)
if (truncate(StringValueCStr(path), pos) < 0)
rb_sys_fail(RSTRING(path)->ptr);
#else
# ifdef HAVE_CHSIZE
@ -2824,7 +2830,7 @@ rb_file_s_truncate(klass, path, len)
rb_sys_fail(RSTRING(path)->ptr);
}
# endif
if (chsize(tmpfd, NUM2OFFT(len)) < 0) {
if (chsize(tmpfd, pos) < 0) {
close(tmpfd);
rb_sys_fail(RSTRING(path)->ptr);
}
@ -2857,8 +2863,10 @@ rb_file_truncate(obj, len)
{
OpenFile *fptr;
FILE *f;
off_t pos;
rb_secure(2);
pos = NUM2OFFT(len);
GetOpenFile(obj, fptr);
if (!(fptr->mode & FMODE_WRITABLE)) {
rb_raise(rb_eIOError, "not opened for writing");
@ -2867,11 +2875,11 @@ rb_file_truncate(obj, len)
fflush(f);
fseeko(f, (off_t)0, SEEK_CUR);
#ifdef HAVE_TRUNCATE
if (ftruncate(fileno(f), NUM2OFFT(len)) < 0)
if (ftruncate(fileno(f), pos) < 0)
rb_sys_fail(fptr->path);
#else
# ifdef HAVE_CHSIZE
if (chsize(fileno(f), NUM2OFFT(len)) < 0)
if (chsize(fileno(f), pos) < 0)
rb_sys_fail(fptr->path);
# else
rb_notimplement();
@ -2958,15 +2966,17 @@ rb_file_flock(obj, operation)
{
#ifndef __CHECKER__
OpenFile *fptr;
int op;
rb_secure(2);
op = NUM2INT(operation);
GetOpenFile(obj, fptr);
if (fptr->mode & FMODE_WRITABLE) {
fflush(GetWriteFile(fptr));
}
retry:
if (flock(fileno(fptr->f), NUM2INT(operation)) < 0) {
if (flock(fileno(fptr->f), op) < 0) {
switch (errno) {
case EAGAIN:
case EACCES:

3
io.c
View file

@ -126,6 +126,9 @@ static VALUE lineno = INT2FIX(0);
# define READ_DATA_PENDING_COUNT(fp) ((fp)->_egptr - (fp)->_gptr)
# define READ_DATA_PENDING_PTR(fp) ((fp)->_gptr)
# endif
#elif defined(HAVE___FPENDING)
# define READ_DATA_PENDING(fp) (__fpending(fp) > 0)
# define READ_DATA_PENDING_COUNT(fp) (__fpending(fp))
#elif defined(FILE_COUNT)
# define READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
# define READ_DATA_PENDING_COUNT(fp) ((fp)->FILE_COUNT)

View file

@ -156,7 +156,7 @@ class CGI
class Session
# The id of this session.
attr_reader :session_id
attr_reader :session_id, :new_session
def Session::callback(dbman) #:nodoc:
Proc.new{
@ -170,7 +170,7 @@ class CGI
# a random number, and a constant string. This routine
# is used internally for automatically generated
# session ids.
def Session::create_new_id
def create_new_id
require 'digest/md5'
md5 = Digest::MD5::new
now = Time::now
@ -179,8 +179,10 @@ class CGI
md5.update(String(rand(0)))
md5.update(String($$))
md5.update('foobar')
@new_session = true
md5.hexdigest[0,16]
end
private :create_new_id
# Create a new CGI::Session object for +request+.
#
@ -239,6 +241,7 @@ class CGI
# end
#
def initialize(request, option={})
@new_session = false
session_key = option['session_key'] || '_session_id'
id = option['session_id']
unless id
@ -367,6 +370,9 @@ class CGI
md5 = Digest::MD5.hexdigest(id)[0,16]
@path = dir+"/"+prefix+md5+suffix
unless File::exist? @path
unless session.new_session
raise RuntimeError, "uninitialized session"
end
@hash = {}
end
end
@ -433,7 +439,12 @@ class CGI
# currently recognised.
def initialize(session, option=nil)
@session_id = session.session_id
GLOBAL_HASH_TABLE[@session_id] ||= {}
unless GLOBAL_HASH_TABLE.key?(@session_id)
unless session.new_session
raise RuntimeError, "uninitialized session"
end
GLOBAL_HASH_TABLE[@session_id] = {}
end
end
# Restore session state.

View file

@ -61,7 +61,10 @@ class CGI
md5 = Digest::MD5.hexdigest(id)[0,16]
path = dir+"/"+prefix+md5
path.untaint
unless File::exist? path
unless File::exist?(path)
unless session.new_session
raise RuntimeError, "uninitialized session"
end
@hash = {}
end
@p = ::PStore.new(path)

View file

@ -1011,8 +1011,8 @@ calculate_must_string(start, end)
{
int mcnt;
int max = 0;
char *p = start;
char *pend = end;
unsigned char *p = start;
unsigned char *pend = end;
char *must = 0;
if (start == NULL) return 0;

View file

@ -16,6 +16,10 @@
#include <stdio.h>
#include <errno.h>
#if defined(HAVE_STDIO_EXT_H)
#include <stdio_ext.h>
#endif
typedef struct OpenFile {
FILE *f; /* stdio ptr for read/write */
FILE *f2; /* additional ptr for rw pipes */

View file

@ -1625,6 +1625,10 @@ rb_str_splice(str, beg, len, val)
VALUE val;
{
if (len < 0) rb_raise(rb_eIndexError, "negative length %ld", len);
StringValue(val);
rb_str_modify(str);
if (RSTRING(str)->len < beg) {
out_of_range:
rb_raise(rb_eIndexError, "index %ld out of string", beg);
@ -1639,8 +1643,6 @@ rb_str_splice(str, beg, len, val)
len = RSTRING(str)->len - beg;
}
StringValue(val);
rb_str_modify(str);
if (len < RSTRING(val)->len) {
/* expand string */
RESIZE_CAPA(str, RSTRING(str)->len + RSTRING(val)->len - len + 1);
@ -2070,7 +2072,7 @@ str_gsub(argc, argv, str, bang)
}
blen = RSTRING(str)->len + 30; /* len + margin */
dest = rb_str_new5(str, 0, blen);
dest = str_new(0, 0, blen);
buf = RSTRING(dest)->ptr;
bp = buf;
sp = cp = RSTRING(str)->ptr;
@ -2086,6 +2088,9 @@ str_gsub(argc, argv, str, bang)
val = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
str_mod_check(str, sp, slen);
if (bang) str_frozen_check(str);
if (val == dest) { /* paranoid chack [ruby-dev:24827] */
rb_raise(rb_eRuntimeError, "block should not cheat");
}
rb_backref_set(match);
}
else {
@ -2147,6 +2152,7 @@ str_gsub(argc, argv, str, bang)
RSTRING(dest)->len = 0;
}
else {
RBASIC(dest)->klass = rb_obj_class(str);
OBJ_INFECT(dest, str);
str = dest;
}