Skip to content

Commit 73deb73

Browse files
author
matz
committed
* numeric.c (flo_divmod): protect float values from GC by
assignment to local variables. [ruby-dev:24873] * string.c (str_mod_check): frozen check should be separated. [ruby-core:3742] * array.c (rb_ary_update): pedantic check to detect rb_ary_to_ary() to modify the receiver. [ruby-dev:24861] * string.c (rb_str_justify): typo fixed. [ruby-dev:24851] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent f556628 commit 73deb73

File tree

6 files changed

+57
-15
lines changed

6 files changed

+57
-15
lines changed

ChangeLog

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Tue Nov 16 23:45:07 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
2+
3+
* numeric.c (flo_divmod): protect float values from GC by
4+
assignment to local variables. [ruby-dev:24873]
5+
16
Tue Nov 16 16:30:21 2004 NAKAMURA Usaku <usa@ruby-lang.org>
27

38
* {bcc32,win32,wince}/setup.mak (-epilogue-): remove config.h and
@@ -13,6 +18,18 @@ Tue Nov 16 11:19:07 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
1318
* lib/test/unit/autorunner.rb (Test::Unit::AutoRunner::options): use
1419
Regexp conversion.
1520

21+
Tue Nov 16 01:41:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
22+
23+
* string.c (str_mod_check): frozen check should be separated.
24+
[ruby-core:3742]
25+
26+
* array.c (rb_ary_update): pedantic check to detect
27+
rb_ary_to_ary() to modify the receiver. [ruby-dev:24861]
28+
29+
Mon Nov 15 13:50:52 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
30+
31+
* string.c (rb_str_justify): typo fixed. [ruby-dev:24851]
32+
1633
Mon Nov 15 11:50:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
1734

1835
* misc/ruby-mode.el (ruby-special-char-p, ruby-parse-partial): handle
@@ -344,6 +361,12 @@ Fri Oct 29 10:00:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
344361
* eval.c (ruby_cleanup): ruby_finalize_1 may cause exception,
345362
should be wrapped by PUSH_TAG/POP_TAG(). [ruby-dev:24627]
346363

364+
Thu Oct 28 08:42:02 2004 Tanaka Akira <akr@m17n.org>
365+
366+
* io.c (argf_forward): use ANSI style.
367+
(argf_read): call argf_forward with argv argument.
368+
[ruby-dev:24624]
369+
347370
Thu Oct 28 23:32:54 2004 akira yamada <akira@ruby-lang.org>
348371

349372
* ext/zlib/zlib.c (zstream_detach_input): resets klass of z->input if

array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,14 +957,14 @@ rb_ary_update(ary, beg, len, rpl)
957957
len = RARRAY(ary)->len - beg;
958958
}
959959

960-
rb_ary_modify(ary);
961960
if (NIL_P(rpl)) {
962961
rlen = 0;
963962
}
964963
else {
965964
rpl = rb_ary_to_ary(rpl);
966965
rlen = RARRAY(rpl)->len;
967966
}
967+
rb_ary_modify(ary);
968968

969969
if (beg >= RARRAY(ary)->len) {
970970
len = beg + rlen;

hash.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,8 +1576,10 @@ rb_hash_update_block_i(key, value, hash)
15761576

15771577
/*
15781578
* call-seq:
1579-
* hsh.merge!(other_hash) => hsh
1580-
* hsh.update(other_hash) => hsh
1579+
* hsh.merge!(other_hash) => hsh
1580+
* hsh.update(other_hash) => hsh
1581+
* hsh.merge!(other_hash){|key, oldval, newval| block} => hsh
1582+
* hsh.update(other_hash){|key, oldval, newval| block} => hsh
15811583
*
15821584
* Adds the contents of <i>other_hash</i> to <i>hsh</i>, overwriting
15831585
* entries with duplicate keys with those from <i>other_hash</i>.
@@ -1603,7 +1605,8 @@ rb_hash_update(hash1, hash2)
16031605

16041606
/*
16051607
* call-seq:
1606-
* hsh.merge(other_hash) -> a_hash
1608+
* hsh.merge(other_hash) -> a_hash
1609+
* hsh.merge(other_hash){|key, oldval, newval| block} -> a_hash
16071610
*
16081611
* Returns a new hash containing the contents of <i>other_hash</i> and
16091612
* the contents of <i>hsh</i>, overwriting entries in <i>hsh</i> with

lib/cgi/session.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class Session
159159
attr_reader :session_id
160160

161161
def Session::callback(dbman) #:nodoc:
162-
lambda{
162+
Proc.new{
163163
dbman[0].close unless dbman.empty?
164164
}
165165
end
@@ -351,17 +351,21 @@ class FileStore
351351
# on Unix systems).
352352
# prefix:: the prefix to add to the session id when generating
353353
# the filename for this session's FileStore file.
354+
# Defaults to "cgi_sid_".
355+
# suffix:: the prefix to add to the session id when generating
356+
# the filename for this session's FileStore file.
354357
# Defaults to the empty string.
355358
#
356359
# This session's FileStore file will be created if it does
357360
# not exist, or opened if it does.
358361
def initialize(session, option={})
359362
dir = option['tmpdir'] || Dir::tmpdir
360-
prefix = option['prefix'] || ''
363+
prefix = option['prefix'] || 'cgi_sid_'
364+
suffix = option['suffix'] || ''
361365
id = session.session_id
362366
require 'digest/md5'
363367
md5 = Digest::MD5.hexdigest(id)[0,16]
364-
@path = dir+"/"+prefix+md5
368+
@path = dir+"/"+prefix+md5+suffix
365369
unless File::exist? @path
366370
@hash = {}
367371
end

numeric.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,9 @@ flo_divmod(x, y)
730730
return rb_num_coerce_bin(x, y);
731731
}
732732
flodivmod(RFLOAT(x)->value, fy, &div, &mod);
733-
return rb_assoc_new(rb_float_new(div), rb_float_new(mod));
733+
x = rb_float_new(div);
734+
y = rb_float_new(mod);
735+
return rb_assoc_new(x, y);
734736
}
735737

736738
/*

string.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ str_mod_check(s, p, len)
5050
}
5151
}
5252

53+
static inline void
54+
str_frozen_check(s)
55+
VALUE s;
56+
{
57+
if (OBJ_FROZEN(s)) {
58+
rb_raise(rb_eRuntimeError, "string frozen");
59+
}
60+
}
61+
5362
static VALUE str_alloc _((VALUE));
5463
static VALUE
5564
str_alloc(klass)
@@ -1958,9 +1967,8 @@ rb_str_sub_bang(argc, argv, str)
19581967

19591968
rb_match_busy(match);
19601969
repl = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
1961-
if (RSTRING(str)->ptr != p || RSTRING(str)->len != len) {
1962-
rb_raise(rb_eRuntimeError, "string modified");
1963-
}
1970+
str_mod_check(str, p, len);
1971+
str_frozen_check(str);
19641972
rb_backref_set(match);
19651973
}
19661974
else {
@@ -2080,6 +2088,7 @@ str_gsub(argc, argv, str, bang)
20802088
rb_match_busy(match);
20812089
val = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
20822090
str_mod_check(str, sp, slen);
2091+
str_frozen_check(str);
20832092
rb_backref_set(match);
20842093
}
20852094
else {
@@ -4458,11 +4467,12 @@ rb_str_justify(argc, argv, str, jflag)
44584467
width = NUM2LONG(w);
44594468
if (width < 0 || RSTRING(str)->len >= width) return rb_str_dup(str);
44604469
res = rb_str_new5(str, 0, width);
4461-
if (argc == 0) {
4470+
if (argc == 2) {
44624471
StringValue(pad);
4463-
if (RSTRING(pad)->len > 0) {
4464-
f = RSTRING(pad)->ptr;
4465-
flen = RSTRING(pad)->len;
4472+
f = RSTRING(pad)->ptr;
4473+
flen = RSTRING(pad)->len;
4474+
if (flen == 0) {
4475+
rb_raise(rb_eArgError, "zero width padding");
44664476
}
44674477
}
44684478
p = RSTRING(res)->ptr;

0 commit comments

Comments
 (0)