Commit graph

196 commits

Author SHA1 Message Date
shyouhei
793f30e38f * eval.c (rb_thread_atfork): When a ruby process forks, its random
seed shall be reinitialized to prevent CVE-2003-0900 situation.
  This bug affects for 1.8 and earlier series, but not for 1.9.
  fixed [ruby-core:34944].

* io.c (pipe_open): ditto.

* random.c (rb_reset_random_seed): ditto.

* intern.h (rb_reset_random_seed): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@31655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-20 21:21:39 +00:00
nobu
0e218279fa * intern.h (VALUE rb_ary_join): I have never seen this function
anywhere.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@30443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-01 01:59:14 +00:00
nobu
dfb8ca93a3 * intern.h (rb_usascii_str_new): macros for forward compatibility.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@29173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-03 03:41:09 +00:00
nobu
b9a8f9826b * defines.h, intern.h, missing.h, ruby.h, st.h, util.h: include
config.h and defines.h for autoconf macros.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@28764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-27 09:33:55 +00:00
akr
c5d882495d * pack.c: backport integer pack/unpack from 1.9 for [ruby-core:21937].
* configure.in: backport RUBY_DEFINT and fixed size integer checks.

* ruby.h: include stdint.h if available.

* bignum.c (rb_big_pack): defined..
  (rb_big_unpack): defined.

* intern.h (rb_big_pack): declared.
  (rb_big_unpack): declared.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@27725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-10 20:53:33 +00:00
knu
c36f4b164b * variable.c, intern.h: Add rb_const_remove().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@27051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-25 18:59:19 +00:00
knu
6476c42337 * object.c, intern.h: Export rb_sym_to_s.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@26218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-31 15:14:00 +00:00
nobu
8d018b2248 * intern.h (rb_thread_join): added prototype. a patch from
Mikhail T. in [ruby-core:26217].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-22 08:27:24 +00:00
nobu
3f0d0b9398 * *.[chy]: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-22 01:00:18 +00:00
nobu
3175b6e7bb * gc.c (Init_stack): use ruby_init_stack. [ruby-dev:34350]
* intern.h (Init_stack): make to call ruby_init_stack.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@23132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-03 09:38:01 +00:00
knu
ed22e8690b * pack.c (rb_utf8_to_uv), intern.h: Rename utf8_to_uv to
rb_utf8_to_uv and export.

* re.c (str_ord): Backport String#ord from 1.9 (sort of);
  requested by Shinichiro Hamaji in [ruby-dev:37247].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@20463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-03 07:36:31 +00:00
nobu
abbe26c60f * gc.c (rb_mark_set): new function to mark keys.
* marshal.c (struct dump_arg, struct load_arg): added wrappers to mark
  data entries.  backport from trunk r13527,r13528,r13961,r16533.
  [ruby-dev:36082]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@19078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 07:53:19 +00:00
knu
6db402c258 * hash.c (rb_hash_set_default_proc): Add Hash#default_proc=;
submitted by Giuseppe Bilotta.  #420

* eval.c (rb_obj_is_proc), intern.h: Export rb_obj_is_proc().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@18580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 09:24:48 +00:00
nobu
363cad3261 * gc.c (STACK_LEVEL_MAX, ruby_stack_length): returns size_t.
[ruby-core:18207]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@18463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-09 23:56:17 +00:00
suke
77ec4ead90 * gc.c: add rb_during_gc(). based on a patch from arton <artonx AT
yahoo.co.jp> at [ruby-dev:35313].   

* intern.h: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-02 17:54:25 +00:00
shyouhei
4a3f1dfb58 * array.c (ary_new, rb_ary_initialize, rb_ary_store,
rb_ary_aplice, rb_ary_times): integer overflows should be
  checked. based on patches from Drew Yao <ayao at apple.com>
  fixed CVE-2008-2726

* string.c (rb_str_buf_append): fixed unsafe use of alloca,
  which led memory corruption. based on a patch from Drew Yao
  <ayao at apple.com> fixed CVE-2008-2726

* sprintf.c (rb_str_format): backported from trunk.

* intern.h: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-19 23:12:46 +00:00
nobu
9ed3d64d1d * suppress warnings on cygwin, mingw and mswin.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-01 19:55:25 +00:00
nobu
1378795e08 * suppress warnings with -Wwrite-string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31 09:28:20 +00:00
knu
5f909db83b * class.c (struct clone_method_data): Add cref.
(clone_method): Properly handle NODE_BMETHOD and NODE_DMETHOD.
  (rb_singleton_class_clone, singleton_class_clone_int): Set a
  proper value to klass and propagate cref. [ruby-core:16238]

* eval.c (rb_block_dup, rb_method_dup), intern.h: Add duplicator
  methods for use from class.c#clone_method().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-26 10:52:56 +00:00
knu
bc3ce4588d * eval.c (rb_proc_new, YIELD_FUNC_LAMBDA): Add a new nd_state
YIELD_FUNC_LAMBDA which avoids automatic `avalue' conversion for
  arguments.  This fixes a bug where [1,[2,3]].map(&:object_id)
  fails.

* intern.h, object.c: Hide rb_proc_new() from intern.h.  It should
  not be considered an official API function yet.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-22 13:51:44 +00:00
knu
5391877f53 * eval.c (rb_f_method_name): New gloval function: __method__;
backported from matzruby / 1.9.

* eval.c (rb_frame_this_func), intern.h: New internal function.

* intern.h (RETURN_ENUMERATOR): Use rb_frame_this_func() instead
  of rb_frame_last_func(), to accommodate the behavior to that of
  1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-21 08:20:52 +00:00
knu
932ac5d35d * eval.c (rb_exec_recursive): New internal function to help
perform recursive operation; backported from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-19 10:29:59 +00:00
knu
87316940b9 * intern.h, hash.c (rb_hash_lookup): New internal function to
check if a key exists in a hash, ignoring #default; backported
  from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-19 09:42:27 +00:00
knu
e926ef5233 * random.c (rb_genrand_int32, rb_genrand_real), intern.h: Export.
* string.c (rb_str_tmp_new), intern.h: New function.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 10:52:17 +00:00
knu
fd8c8d09f4 * enumerator.c, inits.c (rb_call_inits), ruby.h, intern.h,
ext/enumerator, common.mk (OBJS, enumerator.$(OBJEXT)): Make the
  enumerator module built-in,

* enumerator.c: New method: Enumerable::Enumerator#with_index.

* enum.c (enum_each_with_index): Enumerable#each_with_index now
  returns an enumerator instead of raising an exception if no
  block is given.  Enumerable#enum_with_index, formerly defined in
  the enumerator module, is kept as an alias to each_with_index
  for backward compatibility.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-09 11:13:04 +00:00
knu
e6de1a384e * eval.c (rb_obj_method, rb_proc_call), intern.h: Export.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-09 10:47:13 +00:00
nobu
a6eded88af * object.c (rb_check_to_integer): backported for range_step.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-05 01:05:03 +00:00
nobu
9e1da70e14 * intern.h, string.c (rb_str_set_len): added for upgrading path from
1.8 to 1.9. [ruby-dev:32807]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@14727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-27 02:01:24 +00:00
nobu
02da16b167 * eval.c, intern.h, ext/thread/thread.c: should not free queue while
any live threads are waiting.  [ruby-dev:30653]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-20 18:05:40 +00:00
nobu
0ee4c1a6e5 * intern.h (is_ruby_native_thread): removed since declared as an int
function in ruby.h already.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-22 07:07:22 +00:00
nobu
60e3b1b441 * file.c (rb_file_s_rename): deleted code to get rid of a bug of
old Cygwin.

* file.c (rb_file_truncate): added prototype of GetLastError()
  on cygwin.  [ruby-dev:31239]

* intern.h (is_ruby_native_thread): prototype.

* missing/strftime.c (strftime): fix printf format and actual
  arguments.

* ext/Win32API/Win32API.c (Win32API_initialize): ditto.

* ext/tk/tcltklib.c (ip_finalize): ditto.

* ext/dl/ptr.c (rb_dlptr_inspect): ditto.  [ruby-dev:31268]

* ext/dl/sym.c (rb_dlsym_inspect): ditto.

* ext/socket/getnameinfo.c: include stdio.h always.

* ext/win32ole/win32ole.c (ole_hresult2msg, folevariable_name,
  folevariable_ole_type, folevariable_ole_type_detail,
  folevariable_value, folemethod_visible): missing return value.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-22 05:33:47 +00:00
nobu
9bf8a37572 * bignum.c (rb_big_lshift, rb_big_rshift): separated functions
to get rid of infinite recursion.  fixed calculation in edge
  cases.  [ruby-dev:31244]

* numeric.c (rb_fix_lshift, rb_fix_rshift): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-19 05:38:48 +00:00
nobu
409be50fe1 * eval.c (error_handle): no message when exiting by signal.
* eval.c (ruby_cleanup): re-send signal.  [ruby-dev:30516]

* eval.c (rb_thread_interrupt): instantiate SignalException.

* eval.c (rb_thread_signal_raise): now takes signal number instead
  of signal name.

* intern.h (rb_thread_signal_raise, ruby_default_signal): prototypes.

* signal.c (esignal_init): takes a signal number and an optional
  signal name.

* signal.c (interrupt_init): pass SIGINT always.

* signal.c (ruby_default_signal): invoke system default signal
  handler.

* signal.c (rb_signal_exec, trap): handle SIGTERM.  [ruby-dev:30505]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-11 03:09:30 +00:00
knu
af44ff5ea8 * dir.c, win32/win32.c, win32/dir.h, ruby.h, intern.h: Bring
encoding aware globbing support in from trunk.  Dir.[] and
  Dir.glob() can now take many patterns in an array.  Minor fixes
  will follow.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-15 02:52:43 +00:00
aamine
2785c7c05f * ext/strscan/strscan.c (strscan_do_scan): should set kcode option before match. [ruby-dev:29914]
* test/strscan/test_stringscanner.rb: test it.
* re.c: export kcode_set_option and kcode_reset_option (with "rb_" prefix).
* intern.h: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-01-10 09:59:11 +00:00
matz
720cfb3e60 * sprintf.c (rb_str_format): should preserve leading zero
information for negative %b and %x.  [ruby-talk:221347]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-30 02:24:08 +00:00
matz
b6f0af7888 * string.c (rb_str_intern): raise SecurityError only when $SAFE
level is greater than zero.  [ruby-core:08862]

* parse.y (rb_interned_p): new function to check if a string is
  already interned.

* object.c (str_to_id): use rb_str_intern().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-14 07:25:56 +00:00
matz
1b3beecb54 * re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.

* re.c (rb_memcmp): type change from char* to const void*.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-05-16 00:25:18 +00:00
nobu
3da2897dc0 * configure.in, dln.c, file.c, intern.h, missing.h (eaccess): use
system routine if provided.  fixed: [ruby-core:07195]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-01-25 13:30:11 +00:00
ocean
2cb3480d22 * intern.h, file.c: failed to compile on windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-11-23 02:06:00 +00:00
nobu
1cc1c2f77e * object.c (sym_inspect), parse.y (parser_yylex, rb_symname_p): check
if valid as a symbol name more strictly.  [ruby-dev:27478]

* test/ruby/test_symbol.rb: tests for [ruby-core:03573].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-10-22 04:09:24 +00:00
nobu
edecc47890 * eval.c (rb_obj_respond_to): check if obj responds to the given
method with the given visibility.  [ruby-dev:27408]

* eval.c (rb_respond_to): conform to Object#respond_to?.  [ruby-dev:27411]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-10-11 12:42:50 +00:00
nobu
79958f7c74 * eval.c (ev_const_get), variable.c (rb_const_get_0): retry only when
autoload succeeded.

* variable.c (rb_autoload_load): now return true if autoload
  succeeded.  fixed: [ruby-dev:27331]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-28 15:58:32 +00:00
matz
f87aa95e94 * signal.c (sigexit): call rb_thread_signal_exit() instead of
rb_exit().  [ruby-dev:26347]

* eval.c (rb_thread_signal_exit): a new function to exit on main
  thread.

* eval.c (rb_thread_switch): exit status should be retrieved from
  ruby_errinfo.

* eval.c (rb_f_exit): ensure exit(0) should call
  exit(EXIT_SUCCESS).

* missing/mkdir.c: remove. [ruby-core:05177]

* lib/delegate.rb (SimpleDelegator::__setobj__): need check for
  recursive delegation.  [ruby-core:04940]

* misc/ruby-mode.el (ruby-expr-beg): fix looking point drift.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-06-12 16:58:43 +00:00
nobu
744ec6294c * st.h: fix prototypes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-12-03 03:25:49 +00:00
matz
f6348ca0ea * object.c (convert_type): [ruby-core:03845]
* eval.c (rb_funcall_rescue): new function.

* object.c (rb_Array): avoid using rb_respond_to().

* object.c (rb_Integer): ditto.

* eval.c (get_backtrace): no conversion for nil.

* parse.y (reduce_nodes): empty body should return nil.

* lib/cgi/session.rb (CGI::Session::initialize): [ruby-core:03832]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-29 06:13:52 +00:00
matz
c2a9b62fd2 * string.c (rb_str_locktmp): lock string temporarily.
* string.c (str_independent): add tmplock check.

* io.c (io_write): lock output string temporarily.
  [ruby-dev:24649]

* io.c (io_write): use rb_str_locktmp().

* io.c (read_all): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-30 15:33:03 +00:00
matz
2ec51ee0d5 * string.c (str_gsub): reentrant check. [ruby-dev:24432]
* backport all SEGV bug fixes from CVS HEAD.  [ruby-dev:24536]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-20 12:47:20 +00:00
nobu
f11f8e5e92 * intern.h, object.c (rb_class_inherited_p): export.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-18 23:54:34 +00:00
matz
f433be6d9c * io.c (rb_io_s_sysopen): preserve path in the buffer allocated by
ALLOCA_N() to prevent modification.  [ruby-dev:24438]

* io.c (rb_io_mode_flags): preserve append mode flag.
  [ruby-dev:24436]

* io.c (rb_io_modenum_mode): do not use external output buffer.

* string.c (rb_str_justify): differ pointer retrieval to prevent
  padding string modification.  [ruby-dev:24434]

* range.c (range_each_func): allow func to terminate loop by
  returning RANGE_EACH_BREAK.

* range.c (member_i): use RANGE_EACH_BREAK. [ruby-talk:114959]

* marshal.c (r_byte): retrieve pointer from string value for each
  time.  [ruby-dev:24404]

* marshal.c (r_bytes0): ditto.

* enum.c (sort_by_i): re-entrance check added.  [ruby-dev:24399]

* io.c (io_read): should freeze all reading buffer.
  [ruby-dev:24400]

* string.c (rb_str_sum): should use bignums when bits is greater
  than or equals to sizeof(long)*CHAR_BITS. [ruby-dev:24395]

* eval.c (specific_eval): defer pointer retrieval to prevent
  unsafe sourcefile string modification.  [ruby-dev:24382]

* eval.c (specific_eval): defer pointer retrieval to prevent
  unsafe sourcefile string modification.  [ruby-dev:24382]

* string.c (rb_str_sum): wrong cast caused wrong result.
  [ruby-dev:24385]

* enum.c (enum_sort_by): hide temporary array from
  ObjectSpace.each_object.  [ruby-dev:24386]

* string.c (rb_str_sum): check was done with false pointer.
  [ruby-dev:24383]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-06 15:15:12 +00:00