initial import
This commit is contained in:
24
ruby/CVE-2021-41816.patch
Normal file
24
ruby/CVE-2021-41816.patch
Normal file
@@ -0,0 +1,24 @@
|
||||
From c728632c1c09d46cfd4ecbff9caaa3651dd1002a Mon Sep 17 00:00:00 2001
|
||||
From: Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Date: Fri, 3 Sep 2021 19:40:22 +0900
|
||||
Subject: [PATCH] Fix integer overflow
|
||||
|
||||
Make use of the check in rb_alloc_tmp_buffer2.
|
||||
|
||||
https://hackerone.com/reports/1328463
|
||||
---
|
||||
ext/cgi/escape/escape.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/ext/cgi/escape/escape.c
|
||||
+++ b/ext/cgi/escape/escape.c
|
||||
@@ -36,7 +36,8 @@
|
||||
optimized_escape_html(VALUE str)
|
||||
{
|
||||
VALUE vbuf;
|
||||
- char *buf = ALLOCV_N(char, vbuf, RSTRING_LEN(str) * HTML_ESCAPE_MAX_LEN);
|
||||
+ typedef char escape_buf[HTML_ESCAPE_MAX_LEN];
|
||||
+ char *buf = *ALLOCV_N(escape_buf, vbuf, RSTRING_LEN(str));
|
||||
const char *cstr = RSTRING_PTR(str);
|
||||
const char *end = cstr + RSTRING_LEN(str);
|
||||
|
||||
917
ruby/CVE-2021-41817-1.patch
Normal file
917
ruby/CVE-2021-41817-1.patch
Normal file
@@ -0,0 +1,917 @@
|
||||
From 3959accef8da5c128f8a8e2fd54e932a4fb253b0 Mon Sep 17 00:00:00 2001
|
||||
From: Yusuke Endoh <mame@ruby-lang.org>
|
||||
Date: Fri, 12 Nov 2021 12:15:25 +0900
|
||||
Subject: [PATCH] Add length limit option for methods that parses date strings
|
||||
|
||||
`Date.parse` now raises an ArgumentError when a given date string is
|
||||
longer than 128. You can configure the limit by giving `limit` keyword
|
||||
arguments like `Date.parse(str, limit: 1000)`. If you pass `limit: nil`,
|
||||
the limit is disabled.
|
||||
|
||||
Not only `Date.parse` but also the following methods are changed.
|
||||
|
||||
* Date._parse
|
||||
* Date.parse
|
||||
* DateTime.parse
|
||||
* Date._iso8601
|
||||
* Date.iso8601
|
||||
* DateTime.iso8601
|
||||
* Date._rfc3339
|
||||
* Date.rfc3339
|
||||
* DateTime.rfc3339
|
||||
* Date._xmlschema
|
||||
* Date.xmlschema
|
||||
* DateTime.xmlschema
|
||||
* Date._rfc2822
|
||||
* Date.rfc2822
|
||||
* DateTime.rfc2822
|
||||
* Date._rfc822
|
||||
* Date.rfc822
|
||||
* DateTime.rfc822
|
||||
* Date._jisx0301
|
||||
* Date.jisx0301
|
||||
* DateTime.jisx0301
|
||||
---
|
||||
date.gemspec | 2 +-
|
||||
ext/date/date_core.c | 384 +++++++++++++++++++++++++++--------
|
||||
test/date/test_date_parse.rb | 29 +++
|
||||
3 files changed, 326 insertions(+), 89 deletions(-)
|
||||
|
||||
#diff --git a/date.gemspec b/date.gemspec
|
||||
#index 88e5838..1a3ae81 100644
|
||||
#--- a/date.gemspec
|
||||
#+++ b/date.gemspec
|
||||
#@@ -1,7 +1,7 @@
|
||||
# # frozen_string_literal: true
|
||||
# Gem::Specification.new do |s|
|
||||
# s.name = "date"
|
||||
#- s.version = '3.2.0'
|
||||
#+ s.version = '3.2.1'
|
||||
# s.summary = "A subclass of Object includes Comparable module for handling dates."
|
||||
# s.description = "A subclass of Object includes Comparable module for handling dates."
|
||||
#
|
||||
--- a/ext/date/date_core.c
|
||||
+++ b/ext/date/date_core.c
|
||||
@@ -4321,12 +4321,37 @@
|
||||
|
||||
VALUE date__parse(VALUE str, VALUE comp);
|
||||
|
||||
+static size_t
|
||||
+get_limit(VALUE opt)
|
||||
+{
|
||||
+ if (!NIL_P(opt)) {
|
||||
+ VALUE limit = rb_hash_aref(opt, ID2SYM(rb_intern("limit")));
|
||||
+ if (NIL_P(limit)) return SIZE_MAX;
|
||||
+ return NUM2SIZET(limit);
|
||||
+ }
|
||||
+ return 128;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+check_limit(VALUE str, VALUE opt)
|
||||
+{
|
||||
+ StringValue(str);
|
||||
+ size_t slen = RSTRING_LEN(str);
|
||||
+ size_t limit = get_limit(opt);
|
||||
+ if (slen > limit) {
|
||||
+ rb_raise(rb_eArgError,
|
||||
+ "string length (%"PRI_SIZE_PREFIX"u) exceeds the limit %"PRI_SIZE_PREFIX"u", slen, limit);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static VALUE
|
||||
date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE vstr, vcomp, hash;
|
||||
+ VALUE vstr, vcomp, hash, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "11", &vstr, &vcomp);
|
||||
+ rb_scan_args(argc, argv, "11:", &vstr, &vcomp, &opt);
|
||||
+ if (!NIL_P(opt)) argc--;
|
||||
+ check_limit(vstr, opt);
|
||||
StringValue(vstr);
|
||||
if (!rb_enc_str_asciicompat_p(vstr))
|
||||
rb_raise(rb_eArgError,
|
||||
@@ -4341,7 +4366,7 @@
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date._parse(string[, comp=true]) -> hash
|
||||
+ * Date._parse(string[, comp=true], limit: 128) -> hash
|
||||
*
|
||||
* Parses the given representation of date and time, and returns a
|
||||
* hash of parsed elements. This method does not function as a
|
||||
@@ -4352,6 +4377,10 @@
|
||||
* it full.
|
||||
*
|
||||
* Date._parse('2001-02-03') #=> {:year=>2001, :mon=>2, :mday=>3}
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
date_s__parse(int argc, VALUE *argv, VALUE klass)
|
||||
@@ -4361,7 +4390,7 @@
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date.parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]]) -> date
|
||||
+ * Date.parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]], limit: 128) -> date
|
||||
*
|
||||
* Parses the given representation of date and time, and creates a
|
||||
* date object. This method does not function as a validator.
|
||||
@@ -4373,13 +4402,18 @@
|
||||
* Date.parse('2001-02-03') #=> #<Date: 2001-02-03 ...>
|
||||
* Date.parse('20010203') #=> #<Date: 2001-02-03 ...>
|
||||
* Date.parse('3rd Feb 2001') #=> #<Date: 2001-02-03 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
date_s_parse(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, comp, sg;
|
||||
+ VALUE str, comp, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "03", &str, &comp, &sg);
|
||||
+ rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
|
||||
+ if (!NIL_P(opt)) argc--;
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -4391,11 +4425,12 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE argv2[2], hash;
|
||||
-
|
||||
- argv2[0] = str;
|
||||
- argv2[1] = comp;
|
||||
- hash = date_s__parse(2, argv2, klass);
|
||||
+ int argc2 = 2;
|
||||
+ VALUE argv2[3];
|
||||
+ argv2[0] = str;
|
||||
+ argv2[1] = comp;
|
||||
+ if (!NIL_P(opt)) argv2[argc2++] = opt;
|
||||
+ VALUE hash = date_s__parse(argc2, argv2, klass);
|
||||
return d_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
@@ -4409,19 +4444,28 @@
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date._iso8601(string) -> hash
|
||||
+ * Date._iso8601(string, limit: 128) -> hash
|
||||
*
|
||||
* Returns a hash of parsed elements.
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
-date_s__iso8601(VALUE klass, VALUE str)
|
||||
+date_s__iso8601(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
+ VALUE str, opt;
|
||||
+
|
||||
+ rb_scan_args(argc, argv, "1:", &str, &opt);
|
||||
+ check_limit(str, opt);
|
||||
+
|
||||
return date__iso8601(str);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date.iso8601(string='-4712-01-01'[, start=Date::ITALY]) -> date
|
||||
+ * Date.iso8601(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
|
||||
*
|
||||
* Creates a new Date object by parsing from a string according to
|
||||
* some typical ISO 8601 formats.
|
||||
@@ -4429,13 +4473,18 @@
|
||||
* Date.iso8601('2001-02-03') #=> #<Date: 2001-02-03 ...>
|
||||
* Date.iso8601('20010203') #=> #<Date: 2001-02-03 ...>
|
||||
* Date.iso8601('2001-W05-6') #=> #<Date: 2001-02-03 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
date_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, sg;
|
||||
+ VALUE str, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "02", &str, &sg);
|
||||
+ rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
||||
+ if (!NIL_P(opt)) argc--;
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -4445,38 +4494,56 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE hash = date_s__iso8601(klass, str);
|
||||
+ int argc2 = 1;
|
||||
+ VALUE argv2[2];
|
||||
+ argv2[0] = str;
|
||||
+ if (!NIL_P(opt)) argv2[argc2++] = opt;
|
||||
+ VALUE hash = date_s__iso8601(argc2, argv2, klass);
|
||||
return d_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date._rfc3339(string) -> hash
|
||||
+ * Date._rfc3339(string, limit: 128) -> hash
|
||||
*
|
||||
* Returns a hash of parsed elements.
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
-date_s__rfc3339(VALUE klass, VALUE str)
|
||||
+date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
+ VALUE str, opt;
|
||||
+
|
||||
+ rb_scan_args(argc, argv, "1:", &str, &opt);
|
||||
+ check_limit(str, opt);
|
||||
+
|
||||
return date__rfc3339(str);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> date
|
||||
+ * Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> date
|
||||
*
|
||||
* Creates a new Date object by parsing from a string according to
|
||||
* some typical RFC 3339 formats.
|
||||
*
|
||||
* Date.rfc3339('2001-02-03T04:05:06+07:00') #=> #<Date: 2001-02-03 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, sg;
|
||||
+ VALUE str, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "02", &str, &sg);
|
||||
+ rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
||||
+ if (!NIL_P(opt)) argc--;
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -4486,38 +4553,56 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE hash = date_s__rfc3339(klass, str);
|
||||
+ int argc2 = 1;
|
||||
+ VALUE argv2[2];
|
||||
+ argv2[0] = str;
|
||||
+ if (!NIL_P(opt)) argv2[argc2++] = opt;
|
||||
+ VALUE hash = date_s__rfc3339(argc2, argv2, klass);
|
||||
return d_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date._xmlschema(string) -> hash
|
||||
+ * Date._xmlschema(string, limit: 128) -> hash
|
||||
*
|
||||
* Returns a hash of parsed elements.
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
-date_s__xmlschema(VALUE klass, VALUE str)
|
||||
+date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
+ VALUE str, opt;
|
||||
+
|
||||
+ rb_scan_args(argc, argv, "1:", &str, &opt);
|
||||
+ check_limit(str, opt);
|
||||
+
|
||||
return date__xmlschema(str);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date.xmlschema(string='-4712-01-01'[, start=Date::ITALY]) -> date
|
||||
+ * Date.xmlschema(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
|
||||
*
|
||||
* Creates a new Date object by parsing from a string according to
|
||||
* some typical XML Schema formats.
|
||||
*
|
||||
* Date.xmlschema('2001-02-03') #=> #<Date: 2001-02-03 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, sg;
|
||||
+ VALUE str, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "02", &str, &sg);
|
||||
+ rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
||||
+ if (!NIL_P(opt)) argc--;
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -4527,41 +4612,58 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE hash = date_s__xmlschema(klass, str);
|
||||
+ int argc2 = 1;
|
||||
+ VALUE argv2[2];
|
||||
+ argv2[0] = str;
|
||||
+ if (!NIL_P(opt)) argv2[argc2++] = opt;
|
||||
+ VALUE hash = date_s__xmlschema(argc2, argv2, klass);
|
||||
return d_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date._rfc2822(string) -> hash
|
||||
- * Date._rfc822(string) -> hash
|
||||
+ * Date._rfc2822(string, limit: 128) -> hash
|
||||
+ * Date._rfc822(string, limit: 128) -> hash
|
||||
*
|
||||
* Returns a hash of parsed elements.
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
-date_s__rfc2822(VALUE klass, VALUE str)
|
||||
+date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
+ VALUE str, opt;
|
||||
+
|
||||
+ rb_scan_args(argc, argv, "1:", &str, &opt);
|
||||
+ check_limit(str, opt);
|
||||
+
|
||||
return date__rfc2822(str);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> date
|
||||
- * Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> date
|
||||
+ * Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
|
||||
+ * Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
|
||||
*
|
||||
* Creates a new Date object by parsing from a string according to
|
||||
* some typical RFC 2822 formats.
|
||||
*
|
||||
* Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000')
|
||||
* #=> #<Date: 2001-02-03 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, sg;
|
||||
+ VALUE str, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "02", &str, &sg);
|
||||
+ rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -4571,39 +4673,56 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE hash = date_s__rfc2822(klass, str);
|
||||
+ int argc2 = 1;
|
||||
+ VALUE argv2[2];
|
||||
+ argv2[0] = str;
|
||||
+ if (!NIL_P(opt)) argv2[argc2++] = opt;
|
||||
+ VALUE hash = date_s__rfc2822(argc2, argv2, klass);
|
||||
return d_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date._httpdate(string) -> hash
|
||||
+ * Date._httpdate(string, limit: 128) -> hash
|
||||
*
|
||||
* Returns a hash of parsed elements.
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
-date_s__httpdate(VALUE klass, VALUE str)
|
||||
+date_s__httpdate(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
+ VALUE str, opt;
|
||||
+
|
||||
+ rb_scan_args(argc, argv, "1:", &str, &opt);
|
||||
+ check_limit(str, opt);
|
||||
+
|
||||
return date__httpdate(str);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]) -> date
|
||||
+ * Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY], limit: 128) -> date
|
||||
*
|
||||
* Creates a new Date object by parsing from a string according to
|
||||
* some RFC 2616 format.
|
||||
*
|
||||
* Date.httpdate('Sat, 03 Feb 2001 00:00:00 GMT')
|
||||
* #=> #<Date: 2001-02-03 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
date_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, sg;
|
||||
+ VALUE str, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "02", &str, &sg);
|
||||
+ rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -4613,26 +4732,39 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE hash = date_s__httpdate(klass, str);
|
||||
+ int argc2 = 1;
|
||||
+ VALUE argv2[2];
|
||||
+ argv2[0] = str;
|
||||
+ if (!NIL_P(opt)) argv2[argc2++] = opt;
|
||||
+ VALUE hash = date_s__httpdate(argc2, argv2, klass);
|
||||
return d_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date._jisx0301(string) -> hash
|
||||
+ * Date._jisx0301(string, limit: 128) -> hash
|
||||
*
|
||||
* Returns a hash of parsed elements.
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
-date_s__jisx0301(VALUE klass, VALUE str)
|
||||
+date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
+ VALUE str, opt;
|
||||
+
|
||||
+ rb_scan_args(argc, argv, "1:", &str, &opt);
|
||||
+ check_limit(str, opt);
|
||||
+
|
||||
return date__jisx0301(str);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * Date.jisx0301(string='-4712-01-01'[, start=Date::ITALY]) -> date
|
||||
+ * Date.jisx0301(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
|
||||
*
|
||||
* Creates a new Date object by parsing from a string according to
|
||||
* some typical JIS X 0301 formats.
|
||||
@@ -4642,13 +4774,18 @@
|
||||
* For no-era year, legacy format, Heisei is assumed.
|
||||
*
|
||||
* Date.jisx0301('13.02.03') #=> #<Date: 2001-02-03 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, sg;
|
||||
+ VALUE str, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "02", &str, &sg);
|
||||
+ rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
||||
+ if (!NIL_P(opt)) argc--;
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -4658,7 +4795,11 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE hash = date_s__jisx0301(klass, str);
|
||||
+ int argc2 = 1;
|
||||
+ VALUE argv2[2];
|
||||
+ argv2[0] = str;
|
||||
+ if (!NIL_P(opt)) argv2[argc2++] = opt;
|
||||
+ VALUE hash = date_s__jisx0301(argc2, argv2, klass);
|
||||
return d_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
@@ -7994,7 +8135,7 @@
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * DateTime.parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]]) -> datetime
|
||||
+ * DateTime.parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]], limit: 128) -> datetime
|
||||
*
|
||||
* Parses the given representation of date and time, and creates a
|
||||
* DateTime object. This method does not function as a validator.
|
||||
@@ -8008,13 +8149,18 @@
|
||||
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
||||
* DateTime.parse('3rd Feb 2001 04:05:06 PM')
|
||||
* #=> #<DateTime: 2001-02-03T16:05:06+00:00 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
datetime_s_parse(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, comp, sg;
|
||||
+ VALUE str, comp, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "03", &str, &comp, &sg);
|
||||
+ rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
|
||||
+ if (!NIL_P(opt)) argc--;
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -8026,18 +8172,20 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE argv2[2], hash;
|
||||
-
|
||||
- argv2[0] = str;
|
||||
- argv2[1] = comp;
|
||||
- hash = date_s__parse(2, argv2, klass);
|
||||
+ int argc2 = 2;
|
||||
+ VALUE argv2[3];
|
||||
+ argv2[0] = str;
|
||||
+ argv2[1] = comp;
|
||||
+ argv2[2] = opt;
|
||||
+ if (!NIL_P(opt)) argc2++;
|
||||
+ VALUE hash = date_s__parse(argc2, argv2, klass);
|
||||
return dt_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * DateTime.iso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
|
||||
+ * DateTime.iso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
|
||||
*
|
||||
* Creates a new DateTime object by parsing from a string according to
|
||||
* some typical ISO 8601 formats.
|
||||
@@ -8048,13 +8196,18 @@
|
||||
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
||||
* DateTime.iso8601('2001-W05-6T04:05:06+07:00')
|
||||
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, sg;
|
||||
+ VALUE str, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "02", &str, &sg);
|
||||
+ rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
||||
+ if (!NIL_P(opt)) argc--;
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -8064,27 +8217,37 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE hash = date_s__iso8601(klass, str);
|
||||
+ int argc2 = 1;
|
||||
+ VALUE argv2[2];
|
||||
+ argv2[0] = str;
|
||||
+ argv2[1] = opt;
|
||||
+ if (!NIL_P(opt)) argc2--;
|
||||
+ VALUE hash = date_s__iso8601(argc2, argv2, klass);
|
||||
return dt_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * DateTime.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
|
||||
+ * DateTime.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
|
||||
*
|
||||
* Creates a new DateTime object by parsing from a string according to
|
||||
* some typical RFC 3339 formats.
|
||||
*
|
||||
* DateTime.rfc3339('2001-02-03T04:05:06+07:00')
|
||||
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, sg;
|
||||
+ VALUE str, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "02", &str, &sg);
|
||||
+ rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
||||
+ if (!NIL_P(opt)) argc--;
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -8094,27 +8257,37 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE hash = date_s__rfc3339(klass, str);
|
||||
+ int argc2 = 1;
|
||||
+ VALUE argv2[2];
|
||||
+ argv2[0] = str;
|
||||
+ argv2[1] = opt;
|
||||
+ if (!NIL_P(opt)) argc2++;
|
||||
+ VALUE hash = date_s__rfc3339(argc2, argv2, klass);
|
||||
return dt_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * DateTime.xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
|
||||
+ * DateTime.xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
|
||||
*
|
||||
* Creates a new DateTime object by parsing from a string according to
|
||||
* some typical XML Schema formats.
|
||||
*
|
||||
* DateTime.xmlschema('2001-02-03T04:05:06+07:00')
|
||||
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, sg;
|
||||
+ VALUE str, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "02", &str, &sg);
|
||||
+ rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
||||
+ if (!NIL_P(opt)) argc--;
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -8124,28 +8297,38 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE hash = date_s__xmlschema(klass, str);
|
||||
+ int argc2 = 1;
|
||||
+ VALUE argv2[2];
|
||||
+ argv2[0] = str;
|
||||
+ argv2[1] = opt;
|
||||
+ if (!NIL_P(opt)) argc2++;
|
||||
+ VALUE hash = date_s__xmlschema(argc2, argv2, klass);
|
||||
return dt_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * DateTime.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> datetime
|
||||
- * DateTime.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> datetime
|
||||
+ * DateTime.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> datetime
|
||||
+ * DateTime.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> datetime
|
||||
*
|
||||
* Creates a new DateTime object by parsing from a string according to
|
||||
* some typical RFC 2822 formats.
|
||||
*
|
||||
* DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700')
|
||||
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, sg;
|
||||
+ VALUE str, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "02", &str, &sg);
|
||||
+ rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
||||
+ if (!NIL_P(opt)) argc--;
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -8155,7 +8338,12 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE hash = date_s__rfc2822(klass, str);
|
||||
+ int argc2 = 1;
|
||||
+ VALUE argv2[2];
|
||||
+ argv2[0] = str;
|
||||
+ argv2[1] = opt;
|
||||
+ if (!NIL_P(opt)) argc2++;
|
||||
+ VALUE hash = date_s__rfc2822(argc2, argv2, klass);
|
||||
return dt_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
@@ -8169,13 +8357,18 @@
|
||||
*
|
||||
* DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT')
|
||||
* #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, sg;
|
||||
+ VALUE str, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "02", &str, &sg);
|
||||
+ rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
||||
+ if (!NIL_P(opt)) argc--;
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -8185,14 +8378,19 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE hash = date_s__httpdate(klass, str);
|
||||
+ int argc2 = 1;
|
||||
+ VALUE argv2[2];
|
||||
+ argv2[0] = str;
|
||||
+ argv2[1] = opt;
|
||||
+ if (!NIL_P(opt)) argc2++;
|
||||
+ VALUE hash = date_s__httpdate(argc2, argv2, klass);
|
||||
return dt_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
- * DateTime.jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
|
||||
+ * DateTime.jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
|
||||
*
|
||||
* Creates a new DateTime object by parsing from a string according to
|
||||
* some typical JIS X 0301 formats.
|
||||
@@ -8204,13 +8402,18 @@
|
||||
*
|
||||
* DateTime.jisx0301('13.02.03T04:05:06+07:00')
|
||||
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
||||
+ *
|
||||
+ * Raise an ArgumentError when the string length is longer than _limit_.
|
||||
+ * You can stop this check by passing `limit: nil`, but note that
|
||||
+ * it may take a long time to parse.
|
||||
*/
|
||||
static VALUE
|
||||
datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
- VALUE str, sg;
|
||||
+ VALUE str, sg, opt;
|
||||
|
||||
- rb_scan_args(argc, argv, "02", &str, &sg);
|
||||
+ rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
||||
+ if (!NIL_P(opt)) argc--;
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
@@ -8220,7 +8423,12 @@
|
||||
}
|
||||
|
||||
{
|
||||
- VALUE hash = date_s__jisx0301(klass, str);
|
||||
+ int argc2 = 1;
|
||||
+ VALUE argv2[2];
|
||||
+ argv2[0] = str;
|
||||
+ argv2[1] = opt;
|
||||
+ if (!NIL_P(opt)) argc2++;
|
||||
+ VALUE hash = date_s__jisx0301(argc2, argv2, klass);
|
||||
return dt_new_by_frags(klass, hash, sg);
|
||||
}
|
||||
}
|
||||
@@ -9379,19 +9587,19 @@
|
||||
rb_define_singleton_method(cDate, "strptime", date_s_strptime, -1);
|
||||
rb_define_singleton_method(cDate, "_parse", date_s__parse, -1);
|
||||
rb_define_singleton_method(cDate, "parse", date_s_parse, -1);
|
||||
- rb_define_singleton_method(cDate, "_iso8601", date_s__iso8601, 1);
|
||||
+ rb_define_singleton_method(cDate, "_iso8601", date_s__iso8601, -1);
|
||||
rb_define_singleton_method(cDate, "iso8601", date_s_iso8601, -1);
|
||||
- rb_define_singleton_method(cDate, "_rfc3339", date_s__rfc3339, 1);
|
||||
+ rb_define_singleton_method(cDate, "_rfc3339", date_s__rfc3339, -1);
|
||||
rb_define_singleton_method(cDate, "rfc3339", date_s_rfc3339, -1);
|
||||
- rb_define_singleton_method(cDate, "_xmlschema", date_s__xmlschema, 1);
|
||||
+ rb_define_singleton_method(cDate, "_xmlschema", date_s__xmlschema, -1);
|
||||
rb_define_singleton_method(cDate, "xmlschema", date_s_xmlschema, -1);
|
||||
- rb_define_singleton_method(cDate, "_rfc2822", date_s__rfc2822, 1);
|
||||
- rb_define_singleton_method(cDate, "_rfc822", date_s__rfc2822, 1);
|
||||
+ rb_define_singleton_method(cDate, "_rfc2822", date_s__rfc2822, -1);
|
||||
+ rb_define_singleton_method(cDate, "_rfc822", date_s__rfc2822, -1);
|
||||
rb_define_singleton_method(cDate, "rfc2822", date_s_rfc2822, -1);
|
||||
rb_define_singleton_method(cDate, "rfc822", date_s_rfc2822, -1);
|
||||
- rb_define_singleton_method(cDate, "_httpdate", date_s__httpdate, 1);
|
||||
+ rb_define_singleton_method(cDate, "_httpdate", date_s__httpdate, -1);
|
||||
rb_define_singleton_method(cDate, "httpdate", date_s_httpdate, -1);
|
||||
- rb_define_singleton_method(cDate, "_jisx0301", date_s__jisx0301, 1);
|
||||
+ rb_define_singleton_method(cDate, "_jisx0301", date_s__jisx0301, -1);
|
||||
rb_define_singleton_method(cDate, "jisx0301", date_s_jisx0301, -1);
|
||||
|
||||
rb_define_method(cDate, "initialize", date_initialize, -1);
|
||||
--- a/test/date/test_date_parse.rb
|
||||
+++ b/test/date/test_date_parse.rb
|
||||
@@ -1,6 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
require 'test/unit'
|
||||
require 'date'
|
||||
+require 'timeout'
|
||||
|
||||
class TestDateParse < Test::Unit::TestCase
|
||||
|
||||
@@ -1228,4 +1229,32 @@
|
||||
assert_equal(s0, s)
|
||||
end
|
||||
|
||||
+ def test_length_limit
|
||||
+ assert_raise(ArgumentError) { Date._parse("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { Date._iso8601("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { Date._rfc3339("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { Date._xmlschema("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { Date._rfc2822("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { Date._rfc822("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { Date._jisx0301("1" * 1000) }
|
||||
+
|
||||
+ assert_raise(ArgumentError) { Date.parse("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { Date.iso8601("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { Date.rfc3339("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { Date.xmlschema("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { Date.rfc2822("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { Date.rfc822("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { Date.jisx0301("1" * 1000) }
|
||||
+
|
||||
+ assert_raise(ArgumentError) { DateTime.parse("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { DateTime.iso8601("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { DateTime.rfc3339("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { DateTime.xmlschema("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { DateTime.rfc2822("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { DateTime.rfc822("1" * 1000) }
|
||||
+ assert_raise(ArgumentError) { DateTime.jisx0301("1" * 1000) }
|
||||
+
|
||||
+ assert_raise(ArgumentError) { Date._parse("Jan " + "9" * 1000000) }
|
||||
+ assert_raise(Timeout::Error) { Timeout.timeout(1) { Date._parse("Jan " + "9" * 1000000, limit: nil) } }
|
||||
+ end
|
||||
end
|
||||
91
ruby/CVE-2021-41817-2.patch
Normal file
91
ruby/CVE-2021-41817-2.patch
Normal file
@@ -0,0 +1,91 @@
|
||||
From 8f2d7a0c7e52cea8333824bd527822e5449ed83d Mon Sep 17 00:00:00 2001
|
||||
From: Jean Boussier <jean.boussier@gmail.com>
|
||||
Date: Mon, 15 Nov 2021 11:37:40 +0100
|
||||
Subject: [PATCH] `Date._<format>(nil)` should return an empty Hash
|
||||
|
||||
Fix: https://github.com/ruby/date/issues/39
|
||||
|
||||
This is how versions previous to 3.2.1 behaved and Active Support
|
||||
currently rely on this behavior.
|
||||
|
||||
https://github.com/rails/rails/blob/90357af08048ef5076730505f6e7b14a81f33d0c/activesupport/lib/active_support/values/time_zone.rb#L383-L384
|
||||
|
||||
Any Rails application upgrading to date `3.2.1` might run into unexpected errors.
|
||||
---
|
||||
ext/date/date_core.c | 2 ++
|
||||
test/date/test_date_parse.rb | 18 ++++++++++++++++++
|
||||
2 files changed, 20 insertions(+)
|
||||
|
||||
--- a/ext/date/date_core.c
|
||||
+++ b/ext/date/date_core.c
|
||||
@@ -4335,6 +4335,8 @@
|
||||
static void
|
||||
check_limit(VALUE str, VALUE opt)
|
||||
{
|
||||
+ if (NIL_P(str)) return;
|
||||
+
|
||||
StringValue(str);
|
||||
size_t slen = RSTRING_LEN(str);
|
||||
size_t limit = get_limit(opt);
|
||||
--- a/test/date/test_date_parse.rb
|
||||
+++ b/test/date/test_date_parse.rb
|
||||
@@ -848,6 +848,9 @@
|
||||
|
||||
h = Date._iso8601('')
|
||||
assert_equal({}, h)
|
||||
+
|
||||
+ h = Date._iso8601(nil)
|
||||
+ assert_equal({}, h)
|
||||
end
|
||||
|
||||
def test__rfc3339
|
||||
@@ -863,6 +866,9 @@
|
||||
|
||||
h = Date._rfc3339('')
|
||||
assert_equal({}, h)
|
||||
+
|
||||
+ h = Date._rfc3339(nil)
|
||||
+ assert_equal({}, h)
|
||||
end
|
||||
|
||||
def test__xmlschema
|
||||
@@ -945,6 +951,9 @@
|
||||
|
||||
h = Date._xmlschema('')
|
||||
assert_equal({}, h)
|
||||
+
|
||||
+ h = Date._xmlschema(nil)
|
||||
+ assert_equal({}, h)
|
||||
end
|
||||
|
||||
def test__rfc2822
|
||||
@@ -977,6 +986,9 @@
|
||||
|
||||
h = Date._rfc2822('')
|
||||
assert_equal({}, h)
|
||||
+
|
||||
+ h = Date._rfc2822(nil)
|
||||
+ assert_equal({}, h)
|
||||
end
|
||||
|
||||
def test__httpdate
|
||||
@@ -997,6 +1009,9 @@
|
||||
|
||||
h = Date._httpdate('')
|
||||
assert_equal({}, h)
|
||||
+
|
||||
+ h = Date._httpdate(nil)
|
||||
+ assert_equal({}, h)
|
||||
end
|
||||
|
||||
def test__jisx0301
|
||||
@@ -1073,6 +1088,9 @@
|
||||
|
||||
h = Date._jisx0301('')
|
||||
assert_equal({}, h)
|
||||
+
|
||||
+ h = Date._jisx0301(nil)
|
||||
+ assert_equal({}, h)
|
||||
end
|
||||
|
||||
def test_iso8601
|
||||
88
ruby/CVE-2021-41817-3.patch
Normal file
88
ruby/CVE-2021-41817-3.patch
Normal file
@@ -0,0 +1,88 @@
|
||||
From 376c65942bd1d81803f14d37351737df60ec4664 Mon Sep 17 00:00:00 2001
|
||||
From: Jean Boussier <jean.boussier@gmail.com>
|
||||
Date: Tue, 16 Nov 2021 14:03:42 +0100
|
||||
Subject: [PATCH] check_limit: also handle symbols
|
||||
|
||||
---
|
||||
ext/date/date_core.c | 1 +
|
||||
test/date/test_date_parse.rb | 24 ++++++++++++++++++++++++
|
||||
2 files changed, 25 insertions(+)
|
||||
|
||||
--- a/ext/date/date_core.c
|
||||
+++ b/ext/date/date_core.c
|
||||
@@ -4336,6 +4336,7 @@
|
||||
check_limit(VALUE str, VALUE opt)
|
||||
{
|
||||
if (NIL_P(str)) return;
|
||||
+ if (SYMBOL_P(str)) str = rb_sym2str(str);
|
||||
|
||||
StringValue(str);
|
||||
size_t slen = RSTRING_LEN(str);
|
||||
--- a/test/date/test_date_parse.rb
|
||||
+++ b/test/date/test_date_parse.rb
|
||||
@@ -851,6 +851,10 @@
|
||||
|
||||
h = Date._iso8601(nil)
|
||||
assert_equal({}, h)
|
||||
+
|
||||
+ h = Date._iso8601('01-02-03T04:05:06Z'.to_sym)
|
||||
+ assert_equal([2001, 2, 3, 4, 5, 6, 0],
|
||||
+ h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
||||
end
|
||||
|
||||
def test__rfc3339
|
||||
@@ -869,6 +873,10 @@
|
||||
|
||||
h = Date._rfc3339(nil)
|
||||
assert_equal({}, h)
|
||||
+
|
||||
+ h = Date._rfc3339('2001-02-03T04:05:06Z'.to_sym)
|
||||
+ assert_equal([2001, 2, 3, 4, 5, 6, 0],
|
||||
+ h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
||||
end
|
||||
|
||||
def test__xmlschema
|
||||
@@ -954,6 +962,10 @@
|
||||
|
||||
h = Date._xmlschema(nil)
|
||||
assert_equal({}, h)
|
||||
+
|
||||
+ h = Date._xmlschema('2001-02-03'.to_sym)
|
||||
+ assert_equal([2001, 2, 3, nil, nil, nil, nil],
|
||||
+ h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
||||
end
|
||||
|
||||
def test__rfc2822
|
||||
@@ -989,6 +1001,10 @@
|
||||
|
||||
h = Date._rfc2822(nil)
|
||||
assert_equal({}, h)
|
||||
+
|
||||
+ h = Date._rfc2822('Sat, 3 Feb 2001 04:05:06 UT'.to_sym)
|
||||
+ assert_equal([2001, 2, 3, 4, 5, 6, 0],
|
||||
+ h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
||||
end
|
||||
|
||||
def test__httpdate
|
||||
@@ -1012,6 +1028,10 @@
|
||||
|
||||
h = Date._httpdate(nil)
|
||||
assert_equal({}, h)
|
||||
+
|
||||
+ h = Date._httpdate('Sat, 03 Feb 2001 04:05:06 GMT'.to_sym)
|
||||
+ assert_equal([2001, 2, 3, 4, 5, 6, 0],
|
||||
+ h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
||||
end
|
||||
|
||||
def test__jisx0301
|
||||
@@ -1091,6 +1111,10 @@
|
||||
|
||||
h = Date._jisx0301(nil)
|
||||
assert_equal({}, h)
|
||||
+
|
||||
+ h = Date._jisx0301('H13.02.03T04:05:06.07+0100'.to_sym)
|
||||
+ assert_equal([2001, 2, 3, 4, 5, 6, 3600],
|
||||
+ h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
|
||||
end
|
||||
|
||||
def test_iso8601
|
||||
100
ruby/PKGBUILD
Normal file
100
ruby/PKGBUILD
Normal file
@@ -0,0 +1,100 @@
|
||||
# Maintainer: Jesus E. <heckyel@riseup.net>
|
||||
|
||||
pkgname=ruby
|
||||
pkgver=2.7.2
|
||||
_jsonver=2.3.0
|
||||
pkgrel=5
|
||||
pkgdesc="An object-oriented language for quick and easy programming"
|
||||
arch=(i686 x86_64)
|
||||
url='https://www.ruby-lang.org/en/'
|
||||
license=('Simplified-BSD')
|
||||
depends=('libxcrypt' 'gdbm' 'libressl' 'libffi' 'libyaml' 'gmp' 'zlib')
|
||||
makedepends=('doxygen' 'graphviz' 'ttf-dejavu' 'tk')
|
||||
optdepends=('tk: for Ruby/TK')
|
||||
options=(!emptydirs)
|
||||
provides=(rubygems rake)
|
||||
conflicts=(rake)
|
||||
backup=(etc/gemrc)
|
||||
install=$pkgname.install
|
||||
mksource=(https://cache.ruby-lang.org/pub/ruby/${pkgver:0:3}/ruby-${pkgver}.tar.xz
|
||||
https://repo.hyperbola.info:50000/sources/ruby-libre/json_pure-${_jsonver}-gem.tar.gz)
|
||||
source=(https://repo.hyperbola.info:50000/sources/ruby-libre/ruby-libre-${pkgver}.tar.xz{,.sig}
|
||||
patch-ext_openssl_extconf_rb.patch
|
||||
patch-ext_openssl_openssl_missing_h.patch
|
||||
remove-nonfree-ruby-references.patch
|
||||
CVE-2021-41816.patch
|
||||
CVE-2021-41817-1.patch
|
||||
CVE-2021-41817-2.patch
|
||||
CVE-2021-41817-3.patch
|
||||
gemrc)
|
||||
mksha512sums=('7972278b096aa768c7adf2befd26003e18781a29ca317640317d30d93d6e963ded197724c8e2f1dfe1e838c5647176d414a74732a62e931fb50d6f2e0f777349'
|
||||
'eeb6111f18b5cf1acafa6c532be0f58750a2976462e05cc6262baf2f3615259e4ce2ccab115b8dd2c6d37d4ecc9b23bc911efd8823c0d608cb90297a4e4a1ace')
|
||||
sha512sums=('4775ccc2c1bc74ba5fee4e5a904ee2754809b14e36673389f1c6eea7b2955ef8c3ccd374681e845e2e99457a13c742e3b48142a28a1b8d25cd0f571d55be7b45'
|
||||
'SKIP'
|
||||
'ec14f367d8357409e1c5660c76758c596dac6499aa0cc79b13d36cb525d69bd708f498eb5caba098e24e4913f36d3dc2f7b36ba6410418feab7a71f920ab174a'
|
||||
'd4cf308971976c846391f84f822c12e1e005f00c6868e0a1901e82732ff85219e8c1251b56f0a8007700e97a6cd29f372ca444fd6a7aac9dafc909309e0f70b8'
|
||||
'0fad188d5aecbc633418d6c563da1a208dbeaf8f9398014b42dce23be697ddfa6a9b1214bcb7701118b4878a2a0c234b722d4175efe56bda74da0685d1d89794'
|
||||
'5bb4421e36ba0888076cd2b7ff577a417e5bf08de8ca13b1030befce8435057ec330f22e62d78ed13445378db75d19bd2356db4ff061c8f2f65c1a2cb07fe23a'
|
||||
'd44cd0d66e09c058256e76f5f440e73de81098f250d566cf69ed7a50a3ccea79c837f1fddad25df465918a03d2f6d3b722676ffe1efa1bd77afc8b1234438fb7'
|
||||
'b3b6e81e21b37689f23c048569ffb70c524a206f9e6c28f0bf815d2f02abb97200e37fd6a8b8d91ac9fb2a87aae158d8aca461a1c2c87ea4e90ff97b9af6eb21'
|
||||
'158e0fdd44e53b5416dc70775c6ae4f6b5769459e349393e64f3b3e6540e6737a176ee8d58d24de01c0a72d8e30b89476db5798582a00717af8e8e3990e133dd'
|
||||
'8cafd14d414ee3c16aa94f79072bc6c100262f925dc1300e785846c3fabbbbffc1356b8e2223af5684e3340c55032d41231179ffa948bb12e01dbae0f4131911')
|
||||
validpgpkeys=('C92BAA713B8D53D3CAE63FC9E6974752F9704456') # André Silva
|
||||
|
||||
mksource() {
|
||||
rm -rv ruby-${pkgver}/ext/json
|
||||
rm -rv ruby-${pkgver}/test/json
|
||||
cp json_pure-2.3.0.gem ruby-${pkgver}/
|
||||
}
|
||||
|
||||
prepare() {
|
||||
cd ${srcdir}/ruby-${pkgver}
|
||||
|
||||
install -D -m644 json_pure-${_jsonver}.gem gems
|
||||
|
||||
patch -Np1 -i ${srcdir}/remove-nonfree-ruby-references.patch
|
||||
|
||||
# add LibreSSL 2.7 compatibility patch
|
||||
patch -Np0 -i ${srcdir}/patch-ext_openssl_extconf_rb.patch
|
||||
patch -Np0 -i ${srcdir}/patch-ext_openssl_openssl_missing_h.patch
|
||||
|
||||
# CVE-2021-41816
|
||||
patch -Np1 -i ${srcdir}/CVE-2021-41816.patch
|
||||
|
||||
# CVE-2021-41817
|
||||
patch -Np1 -i ${srcdir}/CVE-2021-41817-1.patch
|
||||
patch -Np1 -i ${srcdir}/CVE-2021-41817-2.patch
|
||||
patch -Np1 -i ${srcdir}/CVE-2021-41817-3.patch
|
||||
|
||||
# extract the gem. If it isn't extract like the other bundled gems,
|
||||
# the gem dir will be created with u-w permissions for some reason.
|
||||
install -d -m 755 gems/json_pure-${_jsonver}
|
||||
cd gems/json_pure-${_jsonver}
|
||||
bsdtar xqOf ../json_pure-${_jsonver}.gem data.tar.gz | bsdtar xvzf -
|
||||
}
|
||||
|
||||
build() {
|
||||
cd ${srcdir}/ruby-${pkgver}
|
||||
|
||||
./configure \
|
||||
--prefix=/usr \
|
||||
--sysconfdir=/etc \
|
||||
--localstatedir=/var \
|
||||
--sharedstatedir=/var/lib \
|
||||
--enable-shared \
|
||||
--disable-rpath \
|
||||
--with-dbm-type=gdbm_compat
|
||||
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
cd ${srcdir}/ruby-${pkgver}
|
||||
|
||||
make DESTDIR="${pkgdir}" install-nodoc
|
||||
make DESTDIR="${pkgdir}" install-doc install-capi
|
||||
|
||||
install -D -m644 ${srcdir}/gemrc "${pkgdir}/etc/gemrc"
|
||||
|
||||
install -D -m644 BSDL "${pkgdir}/usr/share/licenses/ruby/BSDL"
|
||||
}
|
||||
5
ruby/gemrc
Normal file
5
ruby/gemrc
Normal file
@@ -0,0 +1,5 @@
|
||||
# Read about the gemrc format at http://guides.rubygems.org/command-reference/#gem-environment
|
||||
|
||||
# --user-install is used to install to $HOME/.gem/ by default since we want to separate
|
||||
# pacman installed gems and gem installed gems
|
||||
gem: --user-install
|
||||
13
ruby/patch-ext_openssl_extconf_rb.patch
Normal file
13
ruby/patch-ext_openssl_extconf_rb.patch
Normal file
@@ -0,0 +1,13 @@
|
||||
$OpenBSD: patch-ext_openssl_extconf_rb,v 1.1 2018/02/23 09:54:25 sthen Exp $
|
||||
|
||||
Index: ext/openssl/extconf.rb
|
||||
--- ext/openssl/extconf.rb.orig
|
||||
+++ ext/openssl/extconf.rb
|
||||
@@ -134,6 +134,7 @@ have_func("HMAC_CTX_free")
|
||||
OpenSSL.check_func("RAND_pseudo_bytes", "openssl/rand.h") # deprecated
|
||||
have_func("X509_STORE_get_ex_data")
|
||||
have_func("X509_STORE_set_ex_data")
|
||||
+have_func("X509_STORE_get_ex_new_index")
|
||||
have_func("X509_CRL_get0_signature")
|
||||
have_func("X509_REQ_get0_signature")
|
||||
have_func("X509_REVOKED_get0_serialNumber")
|
||||
31
ruby/patch-ext_openssl_openssl_missing_h.patch
Normal file
31
ruby/patch-ext_openssl_openssl_missing_h.patch
Normal file
@@ -0,0 +1,31 @@
|
||||
$OpenBSD: patch-ext_openssl_openssl_missing_h,v 1.4 2018/02/23 09:54:25 sthen Exp $
|
||||
|
||||
Index: ext/openssl/openssl_missing.h
|
||||
--- ext/openssl/openssl_missing.h.orig
|
||||
+++ ext/openssl/openssl_missing.h
|
||||
@@ -72,6 +72,9 @@ void ossl_HMAC_CTX_free(HMAC_CTX *);
|
||||
#if !defined(HAVE_X509_STORE_SET_EX_DATA)
|
||||
# define X509_STORE_set_ex_data(x, idx, data) \
|
||||
CRYPTO_set_ex_data(&(x)->ex_data, (idx), (data))
|
||||
+#endif
|
||||
+
|
||||
+#if !defined(HAVE_X509_STORE_GET_EX_NEW_INDEX)
|
||||
# define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \
|
||||
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, (l), (p), \
|
||||
(newf), (dupf), (freef))
|
||||
@@ -145,6 +148,7 @@ void ossl_X509_REQ_get0_signature(const X509_REQ *, co
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_OPAQUE_OPENSSL)
|
||||
+#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL
|
||||
#define IMPL_PKEY_GETTER(_type, _name) \
|
||||
static inline _type *EVP_PKEY_get0_##_type(EVP_PKEY *pkey) { \
|
||||
return pkey->pkey._name; }
|
||||
@@ -196,6 +200,7 @@ IMPL_PKEY_GETTER(EC_KEY, ec)
|
||||
#undef IMPL_PKEY_GETTER
|
||||
#undef IMPL_KEY_ACCESSOR2
|
||||
#undef IMPL_KEY_ACCESSOR3
|
||||
+#endif
|
||||
#endif /* HAVE_OPAQUE_OPENSSL */
|
||||
|
||||
#if !defined(EVP_CTRL_AEAD_GET_TAG)
|
||||
78
ruby/remove-nonfree-ruby-references.patch
Normal file
78
ruby/remove-nonfree-ruby-references.patch
Normal file
@@ -0,0 +1,78 @@
|
||||
diff --git a/common.mk b/common.mk
|
||||
index fd14ab6..28f2bcf 100644
|
||||
--- a/common.mk
|
||||
+++ b/common.mk
|
||||
@@ -36,7 +36,7 @@ UNICODE_DATA_HEADERS = \
|
||||
RUBY_RELEASE_DATE = $(RUBY_RELEASE_YEAR)-$(RUBY_RELEASE_MONTH)-$(RUBY_RELEASE_DAY)
|
||||
RUBYLIB = $(PATH_SEPARATOR)
|
||||
RUBYOPT = -
|
||||
-RUN_OPTS = --disable-gems
|
||||
+RUN_OPTS = --disable-gems -I$(srcdir)/../json-2.3.0/lib
|
||||
|
||||
GITPULLOPTIONS = --rebase
|
||||
|
||||
@@ -1026,8 +1026,7 @@ srcs-ext: $(EXT_SRCS)
|
||||
realclean-srcs-ext::
|
||||
$(Q)$(RM) $(EXT_SRCS)
|
||||
|
||||
-EXTRA_SRCS = $(srcdir)/ext/json/parser/parser.c \
|
||||
- $(srcdir)/ext/date/zonetab.h \
|
||||
+EXTRA_SRCS = $(srcdir)/ext/date/zonetab.h \
|
||||
$(empty)
|
||||
|
||||
srcs-extra: $(EXTRA_SRCS)
|
||||
@@ -1140,11 +1139,6 @@ $(srcdir)/ext/ripper/ripper.c: $(srcdir)/ext/ripper/tools/preproc.rb $(srcdir)/p
|
||||
Q=$(Q) ECHO=$(ECHO) RM="$(RM)" BISON=$(YACC) top_srcdir=../.. srcdir=. VPATH="$${VPATH}" \
|
||||
RUBY="$(BASERUBY)" PATH_SEPARATOR="$(PATH_SEPARATOR)"
|
||||
|
||||
-$(srcdir)/ext/json/parser/parser.c: $(srcdir)/ext/json/parser/parser.rl $(srcdir)/ext/json/parser/prereq.mk
|
||||
- $(ECHO) generating $@
|
||||
- $(Q) $(CHDIR) $(@D) && $(exec) $(MAKE) -f prereq.mk $(mflags) \
|
||||
- Q=$(Q) ECHO=$(ECHO) top_srcdir=../../.. srcdir=. VPATH=../../.. BASERUBY="$(BASERUBY)"
|
||||
-
|
||||
$(srcdir)/ext/date/zonetab.h: $(srcdir)/ext/date/zonetab.list $(srcdir)/ext/date/prereq.mk
|
||||
$(ECHO) generating $@
|
||||
$(Q) $(CHDIR) $(@D) && $(exec) $(MAKE) -f prereq.mk $(mflags) \
|
||||
diff --git a/ext/.document b/ext/.document
|
||||
index 6a49157..97e5120 100644
|
||||
--- a/ext/.document
|
||||
+++ b/ext/.document
|
||||
@@ -27,9 +27,6 @@ gdbm/gdbm.c
|
||||
io/console/console.c
|
||||
io/nonblock/nonblock.c
|
||||
io/wait/wait.c
|
||||
-json/generator/generator.c
|
||||
-json/lib
|
||||
-json/parser/parser.c
|
||||
nkf/lib
|
||||
nkf/nkf.c
|
||||
objspace/objspace.c
|
||||
diff --git a/gems/bundled_gems b/gems/bundled_gems
|
||||
index ce2dd1b..69ae0ae 100644
|
||||
--- a/gems/bundled_gems
|
||||
+++ b/gems/bundled_gems
|
||||
@@ -4,3 +4,4 @@ power_assert 1.1.7 https://github.com/k-tsj/power_assert
|
||||
rake 13.0.1 https://github.com/ruby/rake
|
||||
test-unit 3.3.4 https://github.com/test-unit/test-unit
|
||||
xmlrpc 0.3.0 https://github.com/ruby/xmlrpc
|
||||
+json 2.3.0 https://github.com/flori/json
|
||||
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
|
||||
index 69f03ae..2011334 100644
|
||||
--- a/test/ruby/test_module.rb
|
||||
+++ b/test/ruby/test_module.rb
|
||||
@@ -214,7 +214,6 @@ class TestModule < Test::Unit::TestCase
|
||||
|
||||
ancestors = Object.ancestors
|
||||
mixins = ancestors - [Object, Kernel, BasicObject]
|
||||
- mixins << JSON::Ext::Generator::GeneratorMethods::String if defined?(JSON::Ext::Generator::GeneratorMethods::String)
|
||||
assert_equal([Object, Kernel, BasicObject], ancestors - mixins)
|
||||
assert_equal([String, Comparable, Object, Kernel, BasicObject], String.ancestors - mixins)
|
||||
end
|
||||
@@ -467,7 +466,6 @@ class TestModule < Test::Unit::TestCase
|
||||
assert_equal([Mixin], User.included_modules)
|
||||
|
||||
mixins = Object.included_modules - [Kernel]
|
||||
- mixins << JSON::Ext::Generator::GeneratorMethods::String if defined?(JSON::Ext::Generator::GeneratorMethods::String)
|
||||
assert_equal([Kernel], Object.included_modules - mixins)
|
||||
assert_equal([Comparable, Kernel], String.included_modules - mixins)
|
||||
end
|
||||
22
ruby/ruby.install
Normal file
22
ruby/ruby.install
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
print_gem_default_target() {
|
||||
echo 'The default location of gem installs is $HOME/.gem/ruby'
|
||||
echo 'Add the following line to your PATH if you plan to install using gem'
|
||||
echo '$(ruby -rubygems -e "puts Gem.user_dir")/bin'
|
||||
echo 'If you want to install to the system wide location, you must either:'
|
||||
echo 'edit /etc/gemrc or run gem with the --no-user-install flag.'
|
||||
}
|
||||
|
||||
# arg 1: the new package version
|
||||
post_install() {
|
||||
print_gem_default_target
|
||||
}
|
||||
|
||||
# arg 1: the new package version
|
||||
# arg 2: the old package version
|
||||
post_upgrade() {
|
||||
if [ "$(vercmp $2 1.9.3_p125-4)" -lt 0 ]; then
|
||||
print_gem_default_target
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user