Security update to ruby-1.8.6.287.
This fixes a DNS spoofing vulnerability in Ruby's resolver lib. (CVE-2008-1447) A DoS vulnerability in WEBrick(CVE-2008-3656), problems with Ruby's safelevel implementation (CVE-2008-3655) and a taint check problem in Ruby's dynamic loader (CVE-2008-3657) got fixed as well. This also contains a fix for the REXML DoS issue. (CVE-2008-3790) More information: http://www.ruby-lang.org/en/news/2008/08/08/multiple-vulnerabilities-in-ruby/ http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/ Tested by Jeremy Evans and jcs@. Thanks!
This commit is contained in:
parent
4de0998058
commit
87244aa155
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.62 2008/07/25 20:25:59 sthen Exp $
|
||||
# $OpenBSD: Makefile,v 1.63 2008/09/28 15:43:05 bernd Exp $
|
||||
|
||||
SHARED_ONLY= Yes
|
||||
|
||||
@ -8,13 +8,13 @@ COMMENT-gdbm= gdbm interface for ruby
|
||||
COMMENT-tk= tk interface for ruby
|
||||
|
||||
VERSION= 1.8.6
|
||||
PATCHLEVEL= 114
|
||||
PATCHLEVEL= 287
|
||||
DISTNAME= ruby-${VERSION}-p${PATCHLEVEL}
|
||||
SHARED_LIBS= ruby 2.0
|
||||
PKGNAME-main= ruby-${VERSION}.${PATCHLEVEL}p2
|
||||
PKGNAME-iconv= ruby-iconv-${VERSION}.${PATCHLEVEL}p0
|
||||
PKGNAME-gdbm= ruby-gdbm-${VERSION}.${PATCHLEVEL}p0
|
||||
PKGNAME-tk= ruby-tk-${VERSION}.${PATCHLEVEL}p0
|
||||
PKGNAME-main= ruby-${VERSION}.${PATCHLEVEL}
|
||||
PKGNAME-iconv= ruby-iconv-${VERSION}.${PATCHLEVEL}
|
||||
PKGNAME-gdbm= ruby-gdbm-${VERSION}.${PATCHLEVEL}
|
||||
PKGNAME-tk= ruby-tk-${VERSION}.${PATCHLEVEL}
|
||||
|
||||
CATEGORIES= lang
|
||||
|
||||
@ -55,8 +55,8 @@ MULTI_PACKAGES= -main -iconv -gdbm
|
||||
.if !${FLAVOR:L:Mno_x11}
|
||||
USE_X11= Yes
|
||||
MULTI_PACKAGES+= -tk
|
||||
CONFIGURE_ARGS+= --with-tcl-include=${PREFIX}/include/tcl8.4 \
|
||||
--with-tk-include=${PREFIX}/include/tk8.4 \
|
||||
CONFIGURE_ARGS+= --with-tcl-include=${PREFIX}/include/tcl8.5 \
|
||||
--with-tk-include=${PREFIX}/include/tk8.5 \
|
||||
--with-X11-dir=${X11BASE}
|
||||
.endif
|
||||
|
||||
@ -71,8 +71,8 @@ LIB_DEPENDS-gdbm= gdbm.>=3::databases/gdbm \
|
||||
RUN_DEPENDS-gdbm=
|
||||
|
||||
.if !${FLAVOR:L:Mno_x11}
|
||||
WANTLIB-tk= X11 c m tcl84
|
||||
LIB_DEPENDS-tk= tk84:tk-8.4.*:x11/tk/8.4 \
|
||||
WANTLIB-tk= X11 c m tcl85
|
||||
LIB_DEPENDS-tk= tk85:tk-8.5.*:x11/tk/8.5 \
|
||||
ruby.>=1::lang/ruby
|
||||
RUN_DEPENDS-tk=
|
||||
.endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
MD5 (ruby-1.8.6-p114.tar.gz) = UAqfEWE9bIq23PEr7Bs+0w==
|
||||
RMD160 (ruby-1.8.6-p114.tar.gz) = k2PqPz3t443OOya/5pzL9+rAD3g=
|
||||
SHA1 (ruby-1.8.6-p114.tar.gz) = FJ0ZyqMFnen67zT4BjBkL9YWUa0=
|
||||
SHA256 (ruby-1.8.6-p114.tar.gz) = bN9N+pJm+FGE1YqAAH8PivHZM+0oINpEjBhCaQ5V72o=
|
||||
SIZE (ruby-1.8.6-p114.tar.gz) = 4549333
|
||||
MD5 (ruby-1.8.6-p287.tar.gz) = 9s1RABU0ztU3UzlwenV1Vg==
|
||||
RMD160 (ruby-1.8.6-p287.tar.gz) = UmvPhwILQnqID6xYgRTk3ZPFi5k=
|
||||
SHA1 (ruby-1.8.6-p287.tar.gz) = P496FsBx3186Ag5ifgfggPjNt80=
|
||||
SHA256 (ruby-1.8.6-p287.tar.gz) = ZGPRkyw0/3K3kXSsfSwolA0p0UeSglCSigCg2+5D21c=
|
||||
SIZE (ruby-1.8.6-p287.tar.gz) = 4590393
|
||||
|
@ -1,80 +0,0 @@
|
||||
$OpenBSD: patch-array_c,v 1.1 2008/07/21 09:40:42 bernd Exp $
|
||||
|
||||
Fixes multiple security vulnerabilities.
|
||||
http://secunia.com/advisories/29794/
|
||||
|
||||
Patch against ruby-1.8.6p114 from:
|
||||
http://blog.phusion.nl/assets/r8ee-security-patch-20080623-2.txt
|
||||
and
|
||||
https://launchpad.net/ubuntu/+source/ruby1.8
|
||||
|
||||
1.8.6-p229 and 1.8.7-p21 will break rails applications.
|
||||
|
||||
--- array.c.orig Fri Sep 7 09:46:40 2007
|
||||
+++ array.c Tue Jul 1 20:47:08 2008
|
||||
@@ -20,6 +20,7 @@ VALUE rb_cArray;
|
||||
static ID id_cmp;
|
||||
|
||||
#define ARY_DEFAULT_SIZE 16
|
||||
+#define ARY_MAX_SIZE (LONG_MAX / sizeof(VALUE))
|
||||
|
||||
void
|
||||
rb_mem_clear(mem, size)
|
||||
@@ -120,7 +121,7 @@ ary_new(klass, len)
|
||||
if (len < 0) {
|
||||
rb_raise(rb_eArgError, "negative array size (or size too big)");
|
||||
}
|
||||
- if (len > 0 && len * sizeof(VALUE) <= len) {
|
||||
+ if (len > ARY_MAX_SIZE) {
|
||||
rb_raise(rb_eArgError, "array size too big");
|
||||
}
|
||||
if (len == 0) len++;
|
||||
@@ -293,7 +294,7 @@ rb_ary_initialize(argc, argv, ary)
|
||||
if (len < 0) {
|
||||
rb_raise(rb_eArgError, "negative array size");
|
||||
}
|
||||
- if (len > 0 && len * (long)sizeof(VALUE) <= len) {
|
||||
+ if (len > ARY_MAX_SIZE) {
|
||||
rb_raise(rb_eArgError, "array size too big");
|
||||
}
|
||||
if (len > RARRAY(ary)->aux.capa) {
|
||||
@@ -359,6 +360,10 @@ rb_ary_store(ary, idx, val)
|
||||
}
|
||||
}
|
||||
|
||||
+ if (idx >= ARY_MAX_SIZE) {
|
||||
+ rb_raise(rb_eIndexError, "index %ld too big", idx);
|
||||
+ }
|
||||
+
|
||||
rb_ary_modify(ary);
|
||||
if (idx >= RARRAY(ary)->aux.capa) {
|
||||
long new_capa = RARRAY(ary)->aux.capa / 2;
|
||||
@@ -366,6 +371,9 @@ rb_ary_store(ary, idx, val)
|
||||
if (new_capa < ARY_DEFAULT_SIZE) {
|
||||
new_capa = ARY_DEFAULT_SIZE;
|
||||
}
|
||||
+ if (new_capa >= ARY_MAX_SIZE - idx) {
|
||||
+ new_capa = (ARY_MAX_SIZE - idx) / 2;
|
||||
+ }
|
||||
new_capa += idx;
|
||||
if (new_capa * (long)sizeof(VALUE) <= new_capa) {
|
||||
rb_raise(rb_eArgError, "index too big");
|
||||
@@ -975,6 +983,9 @@ rb_ary_splice(ary, beg, len, rpl)
|
||||
rb_ary_modify(ary);
|
||||
|
||||
if (beg >= RARRAY(ary)->len) {
|
||||
+ if (beg > ARY_MAX_SIZE - rlen) {
|
||||
+ rb_raise(rb_eIndexError, "index %ld too big", beg);
|
||||
+ }
|
||||
len = beg + rlen;
|
||||
if (len >= RARRAY(ary)->aux.capa) {
|
||||
REALLOC_N(RARRAY(ary)->ptr, VALUE, len);
|
||||
@@ -2378,7 +2389,7 @@ rb_ary_times(ary, times)
|
||||
if (len < 0) {
|
||||
rb_raise(rb_eArgError, "negative argument");
|
||||
}
|
||||
- if (LONG_MAX/len < RARRAY(ary)->len) {
|
||||
+ if (ARY_MAX_SIZE/len < RARRAY(ary)->len) {
|
||||
rb_raise(rb_eArgError, "argument too big");
|
||||
}
|
||||
len *= RARRAY(ary)->len;
|
@ -1,66 +0,0 @@
|
||||
$OpenBSD: patch-bignum_c,v 1.1 2008/07/21 09:40:42 bernd Exp $
|
||||
|
||||
Fixes multiple security vulnerabilities.
|
||||
http://secunia.com/advisories/29794/
|
||||
|
||||
Patch against ruby-1.8.6p114 from:
|
||||
http://blog.phusion.nl/assets/r8ee-security-patch-20080623-2.txt
|
||||
and
|
||||
https://launchpad.net/ubuntu/+source/ruby1.8
|
||||
|
||||
1.8.6-p229 and 1.8.7-p21 will break rails applications.
|
||||
|
||||
--- bignum.c.orig Wed Sep 19 04:13:21 2007
|
||||
+++ bignum.c Tue Jul 1 20:47:08 2008
|
||||
@@ -36,8 +36,22 @@ VALUE rb_cBignum;
|
||||
#define BIGLO(x) ((BDIGIT)((x) & (BIGRAD-1)))
|
||||
#define BDIGMAX ((BDIGIT)-1)
|
||||
|
||||
-#define BIGZEROP(x) (RBIGNUM(x)->len == 0 || (RBIGNUM(x)->len == 1 && BDIGITS(x)[0] == 0))
|
||||
+#define BIGZEROP(x) (RBIGNUM(x)->len == 0 || \
|
||||
+ (BDIGITS(x)[0] == 0 && \
|
||||
+ (RBIGNUM(x)->len == 1 || bigzero_p(x))))
|
||||
|
||||
+static int bigzero_p(VALUE);
|
||||
+static int
|
||||
+bigzero_p(x)
|
||||
+ VALUE x;
|
||||
+{
|
||||
+ long i;
|
||||
+ for (i = 0; i < RBIGNUM(x)->len; ++i) {
|
||||
+ if (BDIGITS(x)[i]) return 0;
|
||||
+ }
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
static VALUE
|
||||
bignew_1(klass, len, sign)
|
||||
VALUE klass;
|
||||
@@ -446,7 +460,7 @@ rb_cstr_to_inum(str, base, badcheck)
|
||||
}
|
||||
if (*str == '0') { /* squeeze preceeding 0s */
|
||||
while (*++str == '0');
|
||||
- if (!*str) --str;
|
||||
+ if (!(c = *str) || ISSPACE(c)) --str;
|
||||
}
|
||||
c = *str;
|
||||
c = conv_digit(c);
|
||||
@@ -652,6 +666,9 @@ rb_big2str0(x, base, trim)
|
||||
if (BIGZEROP(x)) {
|
||||
return rb_str_new2("0");
|
||||
}
|
||||
+ if (i >= LONG_MAX/SIZEOF_BDIGITS/CHAR_BIT) {
|
||||
+ rb_raise(rb_eRangeError, "bignum too big to convert into `string'");
|
||||
+ }
|
||||
j = SIZEOF_BDIGITS*CHAR_BIT*i;
|
||||
switch (base) {
|
||||
case 2: break;
|
||||
@@ -706,7 +723,7 @@ rb_big2str0(x, base, trim)
|
||||
while (k--) {
|
||||
s[--j] = ruby_digitmap[num % base];
|
||||
num /= base;
|
||||
- if (!trim && j < 1) break;
|
||||
+ if (!trim && j <= 1) break;
|
||||
if (trim && i == 0 && num == 0) break;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
$OpenBSD: patch-configure,v 1.3 2007/12/27 18:32:33 bernd Exp $
|
||||
--- configure.orig Sun Sep 23 08:19:34 2007
|
||||
+++ configure Mon Sep 24 17:52:28 2007
|
||||
@@ -16674,7 +16674,7 @@ if test "$enable_shared" = 'yes'; then
|
||||
$OpenBSD: patch-configure,v 1.4 2008/09/28 15:43:05 bernd Exp $
|
||||
--- configure.orig Mon Aug 11 02:38:35 2008
|
||||
+++ configure Wed Sep 3 10:30:36 2008
|
||||
@@ -17211,7 +17211,7 @@ if test "$enable_shared" = 'yes'; then
|
||||
;;
|
||||
openbsd*)
|
||||
SOLIBS='$(LIBS)'
|
||||
|
@ -1,51 +0,0 @@
|
||||
$OpenBSD: patch-eval_c,v 1.1 2008/07/21 09:40:42 bernd Exp $
|
||||
|
||||
Fixes multiple security vulnerabilities.
|
||||
http://secunia.com/advisories/29794/
|
||||
|
||||
Patch against ruby-1.8.6p114 from:
|
||||
http://blog.phusion.nl/assets/r8ee-security-patch-20080623-2.txt
|
||||
|
||||
1.8.6-p229 and 1.8.7-p21 will break rails applications.
|
||||
and
|
||||
https://launchpad.net/ubuntu/+source/ruby1.8
|
||||
|
||||
--- eval.c.orig Sun Sep 23 02:01:50 2007
|
||||
+++ eval.c Tue Jul 1 20:47:08 2008
|
||||
@@ -8332,16 +8332,25 @@ proc_clone(self)
|
||||
* MISSING: documentation
|
||||
*/
|
||||
|
||||
+#define PROC_TSHIFT (FL_USHIFT+1)
|
||||
+#define PROC_TMASK (FL_USER1|FL_USER2|FL_USER3)
|
||||
+#define PROC_TMAX (PROC_TMASK >> PROC_TSHIFT)
|
||||
+
|
||||
+static int proc_get_safe_level(VALUE);
|
||||
+
|
||||
static VALUE
|
||||
proc_dup(self)
|
||||
VALUE self;
|
||||
{
|
||||
struct BLOCK *orig, *data;
|
||||
VALUE bind;
|
||||
+ int safe = proc_get_safe_level(self);
|
||||
|
||||
Data_Get_Struct(self, struct BLOCK, orig);
|
||||
bind = Data_Make_Struct(rb_obj_class(self),struct BLOCK,blk_mark,blk_free,data);
|
||||
blk_dup(data, orig);
|
||||
+ if (safe > PROC_TMAX) safe = PROC_TMAX;
|
||||
+ FL_SET(bind, (safe << PROC_TSHIFT) & PROC_TMASK);
|
||||
|
||||
return bind;
|
||||
}
|
||||
@@ -8402,10 +8411,6 @@ rb_f_binding(self)
|
||||
|
||||
return bind;
|
||||
}
|
||||
-
|
||||
-#define PROC_TSHIFT (FL_USHIFT+1)
|
||||
-#define PROC_TMASK (FL_USER1|FL_USER2|FL_USER3)
|
||||
-#define PROC_TMAX (PROC_TMASK >> PROC_TSHIFT)
|
||||
|
||||
#define SAFE_LEVEL_MAX PROC_TMASK
|
||||
|
@ -1,22 +0,0 @@
|
||||
$OpenBSD: patch-intern_h,v 1.1 2008/07/21 09:40:42 bernd Exp $
|
||||
|
||||
Fixes multiple security vulnerabilities.
|
||||
http://secunia.com/advisories/29794/
|
||||
|
||||
Patch against ruby-1.8.6p114 from:
|
||||
http://blog.phusion.nl/assets/r8ee-security-patch-20080623-2.txt
|
||||
and
|
||||
https://launchpad.net/ubuntu/+source/ruby1.8
|
||||
|
||||
1.8.6-p229 and 1.8.7-p21 will break rails applications.
|
||||
|
||||
--- intern.h.orig Wed Aug 22 04:41:24 2007
|
||||
+++ intern.h Tue Jul 1 20:47:08 2008
|
||||
@@ -400,6 +400,7 @@ const char *ruby_signal_name _((int));
|
||||
void ruby_default_signal _((int));
|
||||
/* sprintf.c */
|
||||
VALUE rb_f_sprintf _((int, VALUE*));
|
||||
+VALUE rb_str_format _((int, VALUE*, VALUE));
|
||||
/* string.c */
|
||||
VALUE rb_str_new _((const char*, long));
|
||||
VALUE rb_str_new2 _((const char*));
|
@ -1,34 +0,0 @@
|
||||
$OpenBSD: patch-io_c,v 1.1 2008/07/21 09:40:42 bernd Exp $
|
||||
|
||||
Fixes multiple security vulnerabilities.
|
||||
http://secunia.com/advisories/29794/
|
||||
|
||||
Patch against ruby-1.8.6p114 from:
|
||||
http://blog.phusion.nl/assets/r8ee-security-patch-20080623-2.txt
|
||||
and
|
||||
https://launchpad.net/ubuntu/+source/ruby1.8
|
||||
|
||||
1.8.6-p229 and 1.8.7-p21 will break rails applications.
|
||||
|
||||
--- io.c.orig Tue May 22 18:28:10 2007
|
||||
+++ io.c Tue Jul 1 20:47:08 2008
|
||||
@@ -4851,8 +4851,9 @@ rb_f_select(argc, argv, obj)
|
||||
#if !defined(MSDOS) && !defined(__human68k__)
|
||||
static int
|
||||
io_cntl(fd, cmd, narg, io_p)
|
||||
- int fd, cmd, io_p;
|
||||
+ int fd, io_p;
|
||||
long narg;
|
||||
+ unsigned long cmd;
|
||||
{
|
||||
int retval;
|
||||
|
||||
@@ -4882,7 +4883,7 @@ rb_io_ctl(io, req, arg, io_p)
|
||||
int io_p;
|
||||
{
|
||||
#if !defined(MSDOS) && !defined(__human68k__)
|
||||
- int cmd = NUM2ULONG(req);
|
||||
+ unsigned long cmd = NUM2ULONG(req);
|
||||
OpenFile *fptr;
|
||||
long len = 0;
|
||||
long narg = 0;
|
25
lang/ruby/patches/patch-lib_rexml_document_rb
Normal file
25
lang/ruby/patches/patch-lib_rexml_document_rb
Normal file
@ -0,0 +1,25 @@
|
||||
$OpenBSD: patch-lib_rexml_document_rb,v 1.1 2008/09/28 15:43:05 bernd Exp $
|
||||
|
||||
http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/
|
||||
|
||||
--- lib/rexml/document.rb.orig Sun Nov 4 05:50:15 2007
|
||||
+++ lib/rexml/document.rb Thu Sep 4 09:53:31 2008
|
||||
@@ -18,6 +18,18 @@ module REXML
|
||||
# you create, you must add one; REXML documents do not write a default
|
||||
# declaration for you. See |DECLARATION| and |write|.
|
||||
class Document < Element
|
||||
+ @@entity_expansion_limit = 10_000
|
||||
+ def self.entity_expansion_limit= val
|
||||
+ @@entity_expansion_limit = val
|
||||
+ end
|
||||
+
|
||||
+ def record_entity_expansion!
|
||||
+ @number_of_expansions ||= 0
|
||||
+ @number_of_expansions += 1
|
||||
+ if @number_of_expansions > @@entity_expansion_limit
|
||||
+ raise "Number of entity expansions exceeded, processing aborted."
|
||||
+ end
|
||||
+ end
|
||||
# A convenient default XML declaration. If you want an XML declaration,
|
||||
# the easiest way to add one is mydoc << Document::DECLARATION
|
||||
# +DEPRECATED+
|
14
lang/ruby/patches/patch-lib_rexml_entity_rb
Normal file
14
lang/ruby/patches/patch-lib_rexml_entity_rb
Normal file
@ -0,0 +1,14 @@
|
||||
$OpenBSD: patch-lib_rexml_entity_rb,v 1.1 2008/09/28 15:43:05 bernd Exp $
|
||||
|
||||
http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/
|
||||
|
||||
--- lib/rexml/entity.rb.orig Wed Sep 3 17:38:20 2008
|
||||
+++ lib/rexml/entity.rb Wed Sep 3 17:38:50 2008
|
||||
@@ -73,6 +73,7 @@ module REXML
|
||||
# all entities -- both %ent; and &ent; entities. This differs from
|
||||
# +value()+ in that +value+ only replaces %ent; entities.
|
||||
def unnormalized
|
||||
+ document.record_entity_expansion!
|
||||
v = value()
|
||||
return nil if v.nil?
|
||||
@unnormalized = Text::unnormalize(v, parent)
|
@ -1,40 +0,0 @@
|
||||
$OpenBSD: patch-sprintf_c,v 1.1 2008/07/21 09:40:42 bernd Exp $
|
||||
|
||||
Fixes multiple security vulnerabilities.
|
||||
http://secunia.com/advisories/29794/
|
||||
|
||||
Patch against ruby-1.8.6p114 from:
|
||||
http://blog.phusion.nl/assets/r8ee-security-patch-20080623-2.txt
|
||||
and
|
||||
https://launchpad.net/ubuntu/+source/ruby1.8
|
||||
|
||||
1.8.6-p229 and 1.8.7-p21 will break rails applications.
|
||||
|
||||
--- sprintf.c.orig Wed Aug 22 04:53:31 2007
|
||||
+++ sprintf.c Tue Jul 1 20:47:08 2008
|
||||
@@ -247,7 +247,15 @@ rb_f_sprintf(argc, argv)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
{
|
||||
+ return rb_str_format(argc - 1, argv + 1, GETNTHARG(0));
|
||||
+}
|
||||
+
|
||||
+VALUE
|
||||
+rb_str_format(argc, argv, fmt)
|
||||
+ int argc;
|
||||
+ VALUE *argv;
|
||||
VALUE fmt;
|
||||
+{
|
||||
const char *p, *end;
|
||||
char *buf;
|
||||
int blen, bsiz;
|
||||
@@ -276,7 +284,8 @@ rb_f_sprintf(argc, argv)
|
||||
rb_raise(rb_eArgError, "flag after precision"); \
|
||||
}
|
||||
|
||||
- fmt = GETNTHARG(0);
|
||||
+ ++argc;
|
||||
+ --argv;
|
||||
if (OBJ_TAINTED(fmt)) tainted = 1;
|
||||
StringValue(fmt);
|
||||
fmt = rb_str_new4(fmt);
|
@ -1,153 +0,0 @@
|
||||
$OpenBSD: patch-string_c,v 1.1 2008/07/21 09:40:42 bernd Exp $
|
||||
|
||||
Fixes multiple security vulnerabilities.
|
||||
http://secunia.com/advisories/29794/
|
||||
|
||||
Patch against ruby-1.8.6p114 from:
|
||||
http://blog.phusion.nl/assets/r8ee-security-patch-20080623-2.txt
|
||||
and
|
||||
https://launchpad.net/ubuntu/+source/ruby1.8
|
||||
|
||||
1.8.6-p229 and 1.8.7-p21 will break rails applications.
|
||||
|
||||
--- string.c.orig Fri Sep 7 02:40:27 2007
|
||||
+++ string.c Tue Jul 15 19:05:01 2008
|
||||
@@ -452,22 +452,15 @@ rb_str_times(str, times)
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
-rb_str_format(str, arg)
|
||||
+rb_str_format_m(str, arg)
|
||||
VALUE str, arg;
|
||||
{
|
||||
- VALUE *argv;
|
||||
+ VALUE tmp = rb_check_array_type(arg);
|
||||
|
||||
- if (TYPE(arg) == T_ARRAY) {
|
||||
- argv = ALLOCA_N(VALUE, RARRAY(arg)->len + 1);
|
||||
- argv[0] = str;
|
||||
- MEMCPY(argv+1, RARRAY(arg)->ptr, VALUE, RARRAY(arg)->len);
|
||||
- return rb_f_sprintf(RARRAY(arg)->len+1, argv);
|
||||
+ if (!NIL_P(tmp)) {
|
||||
+ return rb_str_format(RARRAY_LEN(tmp), RARRAY_PTR(tmp), str);
|
||||
}
|
||||
-
|
||||
- argv = ALLOCA_N(VALUE, 2);
|
||||
- argv[0] = str;
|
||||
- argv[1] = arg;
|
||||
- return rb_f_sprintf(2, argv);
|
||||
+ return rb_str_format(1, &arg, str);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -694,19 +687,19 @@ rb_str_resize(str, len)
|
||||
return str;
|
||||
}
|
||||
|
||||
-VALUE
|
||||
-rb_str_buf_cat(str, ptr, len)
|
||||
+static VALUE
|
||||
+str_buf_cat(str, ptr, len)
|
||||
VALUE str;
|
||||
const char *ptr;
|
||||
long len;
|
||||
{
|
||||
- long capa, total;
|
||||
+ long capa, total, off = -1;;
|
||||
|
||||
- if (len == 0) return str;
|
||||
- if (len < 0) {
|
||||
- rb_raise(rb_eArgError, "negative string size (or size too big)");
|
||||
- }
|
||||
rb_str_modify(str);
|
||||
+ if (ptr >= RSTRING(str)->ptr && ptr <= RSTRING(str)->ptr + RSTRING(str)->len) {
|
||||
+ off = ptr - RSTRING(str)->ptr;
|
||||
+ }
|
||||
+ if (len == 0) return 0;
|
||||
if (FL_TEST(str, STR_ASSOC)) {
|
||||
FL_UNSET(str, STR_ASSOC);
|
||||
capa = RSTRING(str)->aux.capa = RSTRING(str)->len;
|
||||
@@ -714,13 +707,23 @@ rb_str_buf_cat(str, ptr, len)
|
||||
else {
|
||||
capa = RSTRING(str)->aux.capa;
|
||||
}
|
||||
+ if (RSTRING(str)->len >= LONG_MAX - len) {
|
||||
+ rb_raise(rb_eArgError, "string sizes too big");
|
||||
+ }
|
||||
total = RSTRING(str)->len+len;
|
||||
if (capa <= total) {
|
||||
while (total > capa) {
|
||||
+ if (capa + 1 >= LONG_MAX / 2) {
|
||||
+ capa = total;
|
||||
+ break;
|
||||
+ }
|
||||
capa = (capa + 1) * 2;
|
||||
}
|
||||
RESIZE_CAPA(str, capa);
|
||||
}
|
||||
+ if (off != -1) {
|
||||
+ ptr = RSTRING(str)->ptr + off;
|
||||
+ }
|
||||
memcpy(RSTRING(str)->ptr + RSTRING(str)->len, ptr, len);
|
||||
RSTRING(str)->len = total;
|
||||
RSTRING(str)->ptr[total] = '\0'; /* sentinel */
|
||||
@@ -729,6 +732,19 @@ rb_str_buf_cat(str, ptr, len)
|
||||
}
|
||||
|
||||
VALUE
|
||||
+rb_str_buf_cat(str, ptr, len)
|
||||
+ VALUE str;
|
||||
+ const char *ptr;
|
||||
+ long len;
|
||||
+{
|
||||
+ if (len == 0) return str;
|
||||
+ if (len < 0) {
|
||||
+ rb_raise(rb_eArgError, "negative string size (or size too big)");
|
||||
+ }
|
||||
+ return str_buf_cat(str, ptr, len);
|
||||
+}
|
||||
+
|
||||
+VALUE
|
||||
rb_str_buf_cat2(str, ptr)
|
||||
VALUE str;
|
||||
const char *ptr;
|
||||
@@ -769,29 +785,8 @@ VALUE
|
||||
rb_str_buf_append(str, str2)
|
||||
VALUE str, str2;
|
||||
{
|
||||
- long capa, len;
|
||||
-
|
||||
- rb_str_modify(str);
|
||||
- if (FL_TEST(str, STR_ASSOC)) {
|
||||
- FL_UNSET(str, STR_ASSOC);
|
||||
- capa = RSTRING(str)->aux.capa = RSTRING(str)->len;
|
||||
- }
|
||||
- else {
|
||||
- capa = RSTRING(str)->aux.capa;
|
||||
- }
|
||||
- len = RSTRING(str)->len+RSTRING(str2)->len;
|
||||
- if (capa <= len) {
|
||||
- while (len > capa) {
|
||||
- capa = (capa + 1) * 2;
|
||||
- }
|
||||
- RESIZE_CAPA(str, capa);
|
||||
- }
|
||||
- memcpy(RSTRING(str)->ptr + RSTRING(str)->len,
|
||||
- RSTRING(str2)->ptr, RSTRING(str2)->len);
|
||||
- RSTRING(str)->len += RSTRING(str2)->len;
|
||||
- RSTRING(str)->ptr[RSTRING(str)->len] = '\0'; /* sentinel */
|
||||
+ str_buf_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
|
||||
OBJ_INFECT(str, str2);
|
||||
-
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -4657,7 +4652,7 @@ Init_String()
|
||||
rb_define_method(rb_cString, "casecmp", rb_str_casecmp, 1);
|
||||
rb_define_method(rb_cString, "+", rb_str_plus, 1);
|
||||
rb_define_method(rb_cString, "*", rb_str_times, 1);
|
||||
- rb_define_method(rb_cString, "%", rb_str_format, 1);
|
||||
+ rb_define_method(rb_cString, "%", rb_str_format_m, 1);
|
||||
rb_define_method(rb_cString, "[]", rb_str_aref_m, -1);
|
||||
rb_define_method(rb_cString, "[]=", rb_str_aset_m, -1);
|
||||
rb_define_method(rb_cString, "insert", rb_str_insert, 2);
|
@ -1,4 +1,4 @@
|
||||
@comment $OpenBSD: PLIST-main,v 1.4 2008/07/21 09:40:42 bernd Exp $
|
||||
@comment $OpenBSD: PLIST-main,v 1.5 2008/09/28 15:43:05 bernd Exp $
|
||||
@pkgpath lang/ruby
|
||||
bin/erb
|
||||
bin/irb
|
||||
@ -95,6 +95,7 @@ lib/ruby/${REV}/${SUB}/fcntl.so
|
||||
lib/ruby/${REV}/${SUB}/intern.h
|
||||
lib/ruby/${REV}/${SUB}/io/
|
||||
lib/ruby/${REV}/${SUB}/io/wait.so
|
||||
lib/ruby/${REV}/${SUB}/largefile.h
|
||||
lib/ruby/${REV}/${SUB}/missing.h
|
||||
lib/ruby/${REV}/${SUB}/nkf.so
|
||||
lib/ruby/${REV}/${SUB}/node.h
|
||||
@ -6471,20 +6472,22 @@ share/ri/${REV}/system/Resolv/DNS/Requester/ConnectedUDP/Sender/
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/ConnectedUDP/Sender/cdesc-Sender.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/ConnectedUDP/Sender/send-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/ConnectedUDP/cdesc-ConnectedUDP.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/ConnectedUDP/close-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/ConnectedUDP/new-c.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/ConnectedUDP/recv_reply-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/ConnectedUDP/sender-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/RequestError/
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/RequestError/cdesc-RequestError.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/Sender/
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/Sender/cdesc-Sender.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/Sender/new-c.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/Sender/recv-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/TCP/
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/TCP/Sender/
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/TCP/Sender/cdesc-Sender.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/TCP/Sender/send-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/TCP/cdesc-TCP.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/TCP/close-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/TCP/new-c.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/TCP/recv_reply-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/TCP/sender-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/UnconnectedUDP/
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/UnconnectedUDP/Sender/
|
||||
@ -6492,12 +6495,14 @@ share/ri/${REV}/system/Resolv/DNS/Requester/UnconnectedUDP/Sender/cdesc-Sender.y
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/UnconnectedUDP/Sender/new-c.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/UnconnectedUDP/Sender/send-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/UnconnectedUDP/cdesc-UnconnectedUDP.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/UnconnectedUDP/close-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/UnconnectedUDP/new-c.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/UnconnectedUDP/recv_reply-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/UnconnectedUDP/sender-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/cdesc-Requester.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/close-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/delete-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/new-c.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Requester/request-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Resource/
|
||||
share/ri/${REV}/system/Resolv/DNS/Resource/%3d%3d-i.yaml
|
||||
share/ri/${REV}/system/Resolv/DNS/Resource/ANY/
|
||||
@ -9249,6 +9254,8 @@ share/ri/${REV}/system/TimeExtentionTest/cdesc-TimeExtentionTest.yaml
|
||||
share/ri/${REV}/system/Timeout/
|
||||
share/ri/${REV}/system/Timeout/Error/
|
||||
share/ri/${REV}/system/Timeout/Error/cdesc-Error.yaml
|
||||
share/ri/${REV}/system/Timeout/ExitException/
|
||||
share/ri/${REV}/system/Timeout/ExitException/cdesc-ExitException.yaml
|
||||
share/ri/${REV}/system/Timeout/cdesc-Timeout.yaml
|
||||
share/ri/${REV}/system/Timeout/timeout-i.yaml
|
||||
share/ri/${REV}/system/TokenStream/
|
||||
@ -9771,6 +9778,8 @@ share/ri/${REV}/system/WEBrick/HTTPServlet/FileHandler/service-i.yaml
|
||||
share/ri/${REV}/system/WEBrick/HTTPServlet/FileHandler/set_dir_list-i.yaml
|
||||
share/ri/${REV}/system/WEBrick/HTTPServlet/FileHandler/set_filename-i.yaml
|
||||
share/ri/${REV}/system/WEBrick/HTTPServlet/FileHandler/shift_path_info-i.yaml
|
||||
share/ri/${REV}/system/WEBrick/HTTPServlet/FileHandler/trailing_pathsep%3f-i.yaml
|
||||
share/ri/${REV}/system/WEBrick/HTTPServlet/FileHandler/windows_ambiguous_name%3f-i.yaml
|
||||
share/ri/${REV}/system/WEBrick/HTTPServlet/HTTPServletError/
|
||||
share/ri/${REV}/system/WEBrick/HTTPServlet/HTTPServletError/cdesc-HTTPServletError.yaml
|
||||
share/ri/${REV}/system/WEBrick/HTTPServlet/ProcHandler/
|
||||
|
Loading…
Reference in New Issue
Block a user