Skip to content

Commit a35e0a7

Browse files
committed
Merge branch 'master-2.2' into dist/2.2/trusty
2 parents c567d8d + 1af4a4d commit a35e0a7

32 files changed

+474
-165
lines changed

ChangeLog

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1+
Thu Sep 14 20:44:26 2017 SHIBATA Hiroshi <[email protected]>
2+
3+
* ext/json: bump to version 1.8.1.1. [Backport #13853]
4+
5+
Thu Sep 14 20:39:39 2017 Kazuki Yamaguchi <[email protected]>
6+
7+
asn1: fix out-of-bounds read in decoding constructed objects
8+
9+
* OpenSSL::ASN1.{decode,decode_all,traverse}: have a bug of
10+
out-of-bounds read. int_ossl_asn1_decode0_cons() does not give the
11+
correct available length to ossl_asn1_decode() when decoding the
12+
inner components of a constructed object. This can cause
13+
out-of-bounds read if a crafted input given.
14+
15+
Reference: https://hackerone.com/reports/170316
16+
https://github.com/ruby/openssl/commit/1648afef33c1d97fb203c82291b8a61269e85d3b
17+
18+
Thu Sep 14 20:36:54 2017 Yusuke Endoh <[email protected]>
19+
20+
lib/webrick/log.rb: sanitize any type of logs
21+
22+
It had failed to sanitize some type of exception messages. Reported and
23+
patched by Yusuke Endoh (mame) at https://hackerone.com/reports/223363
24+
25+
Thu Sep 14 20:33:52 2017 Nobuyoshi Nakada <[email protected]>
26+
27+
Fix space flag when Inf/NaN and width==3
28+
29+
* sprintf.c (rb_str_format): while "% 2f" and "% 4f" result in " Inf"
30+
and " Inf" respectively, "% 3f" results in "Inf" (no space).
31+
32+
Refactor "%f" % Inf/NaN
33+
34+
* sprintf.c (rb_str_format): as for non-finite float, calculate the
35+
exact needed size with the space flag.
36+
37+
Sun Sep 10 10:10:05 2017 SHIBATA Hiroshi <[email protected]>
38+
39+
* lib/rubygems: fix several vulnerabilities in RubyGems; bump to version
40+
2.4.5.3. [Backport #13842]
41+
42+
Sat Sep 9 21:08:24 2017 SHIBATA Hiroshi <[email protected]>
43+
44+
* ext/psych/yaml: update libyaml to 0.1.7.
45+
46+
* ext/psych/psych.gemspec: bump version to 2.0.8.1.
47+
148
Tue Mar 28 15:39:26 2017 Nobuyoshi Nakada <[email protected]>
249

350
configure.in: syscall is deprecated on macOS

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
ruby2.2 (2.2.8-0nkmi1) unstable; urgency=medium
2+
3+
* new upstream version
4+
5+
-- Sorah Fukumori <[email protected]> Thu, 14 Sep 2017 16:58:33 +0000
6+
17
ruby2.2 (2.2.7-0nkmi1~trusty) trusty; urgency=medium
28

39
* new upstream version

ext/json/generator/generator.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static char *fstrndup(const char *ptr, unsigned long len) {
301301
char *result;
302302
if (len <= 0) return NULL;
303303
result = ALLOC_N(char, len);
304-
memccpy(result, ptr, 0, len);
304+
memcpy(result, ptr, len);
305305
return result;
306306
}
307307

@@ -1055,7 +1055,7 @@ static VALUE cState_indent_set(VALUE self, VALUE indent)
10551055
}
10561056
} else {
10571057
if (state->indent) ruby_xfree(state->indent);
1058-
state->indent = strdup(RSTRING_PTR(indent));
1058+
state->indent = fstrndup(RSTRING_PTR(indent), len);
10591059
state->indent_len = len;
10601060
}
10611061
return Qnil;
@@ -1093,7 +1093,7 @@ static VALUE cState_space_set(VALUE self, VALUE space)
10931093
}
10941094
} else {
10951095
if (state->space) ruby_xfree(state->space);
1096-
state->space = strdup(RSTRING_PTR(space));
1096+
state->space = fstrndup(RSTRING_PTR(space), len);
10971097
state->space_len = len;
10981098
}
10991099
return Qnil;
@@ -1129,7 +1129,7 @@ static VALUE cState_space_before_set(VALUE self, VALUE space_before)
11291129
}
11301130
} else {
11311131
if (state->space_before) ruby_xfree(state->space_before);
1132-
state->space_before = strdup(RSTRING_PTR(space_before));
1132+
state->space_before = fstrndup(RSTRING_PTR(space_before), len);
11331133
state->space_before_len = len;
11341134
}
11351135
return Qnil;
@@ -1166,7 +1166,7 @@ static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)
11661166
}
11671167
} else {
11681168
if (state->object_nl) ruby_xfree(state->object_nl);
1169-
state->object_nl = strdup(RSTRING_PTR(object_nl));
1169+
state->object_nl = fstrndup(RSTRING_PTR(object_nl), len);
11701170
state->object_nl_len = len;
11711171
}
11721172
return Qnil;
@@ -1201,7 +1201,7 @@ static VALUE cState_array_nl_set(VALUE self, VALUE array_nl)
12011201
}
12021202
} else {
12031203
if (state->array_nl) ruby_xfree(state->array_nl);
1204-
state->array_nl = strdup(RSTRING_PTR(array_nl));
1204+
state->array_nl = fstrndup(RSTRING_PTR(array_nl), len);
12051205
state->array_nl_len = len;
12061206
}
12071207
return Qnil;

ext/json/generator/generator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef _GENERATOR_H_
22
#define _GENERATOR_H_
33

4-
#include <string.h>
54
#include <math.h>
65
#include <ctype.h>
76

ext/json/lib/json/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module JSON
22
# JSON version
3-
VERSION = '1.8.1'
3+
VERSION = '1.8.1.1'
44
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
55
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
66
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:

ext/openssl/ossl_asn1.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -871,19 +871,18 @@ int_ossl_asn1_decode0_cons(unsigned char **pp, long max_len, long length,
871871
{
872872
VALUE value, asn1data, ary;
873873
int infinite;
874-
long off = *offset;
874+
long available_len, off = *offset;
875875

876876
infinite = (j == 0x21);
877877
ary = rb_ary_new();
878878

879-
while (length > 0 || infinite) {
879+
available_len = infinite ? max_len : length;
880+
while (available_len > 0) {
880881
long inner_read = 0;
881-
value = ossl_asn1_decode0(pp, max_len, &off, depth + 1, yield, &inner_read);
882+
value = ossl_asn1_decode0(pp, available_len, &off, depth + 1, yield, &inner_read);
882883
*num_read += inner_read;
883-
max_len -= inner_read;
884+
available_len -= inner_read;
884885
rb_ary_push(ary, value);
885-
if (length > 0)
886-
length -= inner_read;
887886

888887
if (infinite &&
889888
NUM2INT(ossl_asn1_get_tag(value)) == V_ASN1_EOC &&
@@ -974,7 +973,7 @@ ossl_asn1_decode0(unsigned char **pp, long length, long *offset, int depth,
974973
if(j & V_ASN1_CONSTRUCTED) {
975974
*pp += hlen;
976975
off += hlen;
977-
asn1data = int_ossl_asn1_decode0_cons(pp, length, len, &off, depth, yield, j, tag, tag_class, &inner_read);
976+
asn1data = int_ossl_asn1_decode0_cons(pp, length - hlen, len, &off, depth, yield, j, tag, tag_class, &inner_read);
978977
inner_read += hlen;
979978
}
980979
else {

ext/psych/psych.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gem::Specification.new do |s|
44
s.name = "psych"
5-
s.version = "2.0.8"
5+
s.version = "2.0.8.1"
66

77
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
88
s.require_paths = ["lib"]

ext/psych/yaml/api.c

Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ yaml_emitter_delete(yaml_emitter_t *emitter)
395395
}
396396
QUEUE_DEL(emitter, emitter->events);
397397
STACK_DEL(emitter, emitter->indents);
398-
while (!STACK_EMPTY(emitter, emitter->tag_directives)) {
398+
while (!STACK_EMPTY(empty, emitter->tag_directives)) {
399399
yaml_tag_directive_t tag_directive = POP(emitter, emitter->tag_directives);
400400
yaml_free(tag_directive.handle);
401401
yaml_free(tag_directive.prefix);
@@ -415,7 +415,7 @@ yaml_string_write_handler(void *data, unsigned char *buffer, size_t size)
415415
{
416416
yaml_emitter_t *emitter = data;
417417

418-
if (emitter->output.string.size + *emitter->output.string.size_written
418+
if (emitter->output.string.size - *emitter->output.string.size_written
419419
< size) {
420420
memcpy(emitter->output.string.buffer
421421
+ *emitter->output.string.size_written,
@@ -822,7 +822,6 @@ yaml_scalar_event_initialize(yaml_event_t *event,
822822
yaml_char_t *anchor_copy = NULL;
823823
yaml_char_t *tag_copy = NULL;
824824
yaml_char_t *value_copy = NULL;
825-
size_t value_length;
826825

827826
assert(event); /* Non-NULL event object is expected. */
828827
assert(value); /* Non-NULL anchor is expected. */
@@ -840,19 +839,16 @@ yaml_scalar_event_initialize(yaml_event_t *event,
840839
}
841840

842841
if (length < 0) {
843-
value_length = strlen((char *)value);
844-
}
845-
else {
846-
value_length = (size_t)length;
842+
length = strlen((char *)value);
847843
}
848844

849-
if (!yaml_check_utf8(value, value_length)) goto error;
850-
value_copy = yaml_malloc(value_length+1);
845+
if (!yaml_check_utf8(value, length)) goto error;
846+
value_copy = yaml_malloc(length+1);
851847
if (!value_copy) goto error;
852-
memcpy(value_copy, value, value_length);
853-
value_copy[value_length] = '\0';
848+
memcpy(value_copy, value, length);
849+
value_copy[length] = '\0';
854850

855-
SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy, value_length,
851+
SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy, length,
856852
plain_implicit, quoted_implicit, style, mark, mark);
857853

858854
return 1;
@@ -1206,8 +1202,6 @@ yaml_document_add_scalar(yaml_document_t *document,
12061202
yaml_char_t *tag_copy = NULL;
12071203
yaml_char_t *value_copy = NULL;
12081204
yaml_node_t node;
1209-
size_t value_length;
1210-
ptrdiff_t ret;
12111205

12121206
assert(document); /* Non-NULL document object is expected. */
12131207
assert(value); /* Non-NULL value is expected. */
@@ -1221,26 +1215,19 @@ yaml_document_add_scalar(yaml_document_t *document,
12211215
if (!tag_copy) goto error;
12221216

12231217
if (length < 0) {
1224-
value_length = strlen((char *)value);
1225-
}
1226-
else {
1227-
value_length = (size_t)length;
1218+
length = strlen((char *)value);
12281219
}
12291220

1230-
if (!yaml_check_utf8(value, value_length)) goto error;
1231-
value_copy = yaml_malloc(value_length+1);
1221+
if (!yaml_check_utf8(value, length)) goto error;
1222+
value_copy = yaml_malloc(length+1);
12321223
if (!value_copy) goto error;
1233-
memcpy(value_copy, value, value_length);
1234-
value_copy[value_length] = '\0';
1224+
memcpy(value_copy, value, length);
1225+
value_copy[length] = '\0';
12351226

1236-
SCALAR_NODE_INIT(node, tag_copy, value_copy, value_length, style, mark, mark);
1227+
SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark);
12371228
if (!PUSH(&context, document->nodes, node)) goto error;
12381229

1239-
ret = document->nodes.top - document->nodes.start;
1240-
#if PTRDIFF_MAX > INT_MAX
1241-
if (ret > INT_MAX) goto error;
1242-
#endif
1243-
return (int)ret;
1230+
return document->nodes.top - document->nodes.start;
12441231

12451232
error:
12461233
yaml_free(tag_copy);
@@ -1268,7 +1255,6 @@ yaml_document_add_sequence(yaml_document_t *document,
12681255
yaml_node_item_t *top;
12691256
} items = { NULL, NULL, NULL };
12701257
yaml_node_t node;
1271-
ptrdiff_t ret;
12721258

12731259
assert(document); /* Non-NULL document object is expected. */
12741260

@@ -1286,11 +1272,7 @@ yaml_document_add_sequence(yaml_document_t *document,
12861272
style, mark, mark);
12871273
if (!PUSH(&context, document->nodes, node)) goto error;
12881274

1289-
ret = document->nodes.top - document->nodes.start;
1290-
#if PTRDIFF_MAX > INT_MAX
1291-
if (ret > INT_MAX) goto error;
1292-
#endif
1293-
return (int)ret;
1275+
return document->nodes.top - document->nodes.start;
12941276

12951277
error:
12961278
STACK_DEL(&context, items);
@@ -1318,7 +1300,6 @@ yaml_document_add_mapping(yaml_document_t *document,
13181300
yaml_node_pair_t *top;
13191301
} pairs = { NULL, NULL, NULL };
13201302
yaml_node_t node;
1321-
ptrdiff_t ret;
13221303

13231304
assert(document); /* Non-NULL document object is expected. */
13241305

@@ -1336,11 +1317,7 @@ yaml_document_add_mapping(yaml_document_t *document,
13361317
style, mark, mark);
13371318
if (!PUSH(&context, document->nodes, node)) goto error;
13381319

1339-
ret = document->nodes.top - document->nodes.start;
1340-
#if PTRDIFF_MAX > INT_MAX
1341-
if (ret > INT_MAX) goto error;
1342-
#endif
1343-
return (int)ret;
1320+
return document->nodes.top - document->nodes.start;
13441321

13451322
error:
13461323
STACK_DEL(&context, pairs);

ext/psych/yaml/config.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#define PACKAGE_NAME "yaml"
22
#define PACKAGE_TARNAME "yaml"
3-
#define PACKAGE_VERSION "0.1.6"
4-
#define PACKAGE_STRING "yaml 0.1.6"
5-
#define PACKAGE_BUGREPORT "http://pyyaml.org/newticket?component libyaml"
6-
#define PACKAGE_URL ""
3+
#define PACKAGE_VERSION "0.1.7"
4+
#define PACKAGE_STRING "yaml 0.1.7"
5+
#define PACKAGE_BUGREPORT "https://github.com/yaml/libyaml/issues"
6+
#define PACKAGE_URL "https://github.com/yaml/libyaml"
77
#define YAML_VERSION_MAJOR 0
88
#define YAML_VERSION_MINOR 1
9-
#define YAML_VERSION_PATCH 6
10-
#define YAML_VERSION_STRING "0.1.6"
9+
#define YAML_VERSION_PATCH 7
10+
#define YAML_VERSION_STRING "0.1.7"

ext/psych/yaml/emitter.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#define WRITE_BREAK(emitter,string) \
5454
(FLUSH(emitter) \
5555
&& (CHECK(string,'\n') ? \
56-
((void)PUT_BREAK(emitter), \
56+
(PUT_BREAK(emitter), \
5757
string.pointer ++, \
5858
1) : \
5959
(COPY(emitter->buffer,string), \
@@ -221,7 +221,7 @@ yaml_emitter_write_indent(yaml_emitter_t *emitter);
221221

222222
static int
223223
yaml_emitter_write_indicator(yaml_emitter_t *emitter,
224-
const char *indicator, int need_whitespace,
224+
char *indicator, int need_whitespace,
225225
int is_whitespace, int is_indention);
226226

227227
static int
@@ -1493,7 +1493,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
14931493
int break_space = 0;
14941494
int space_break = 0;
14951495

1496-
int preceeded_by_whitespace = 0;
1496+
int preceded_by_whitespace = 0;
14971497
int followed_by_whitespace = 0;
14981498
int previous_space = 0;
14991499
int previous_break = 0;
@@ -1524,7 +1524,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
15241524
flow_indicators = 1;
15251525
}
15261526

1527-
preceeded_by_whitespace = 1;
1527+
preceded_by_whitespace = 1;
15281528
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
15291529

15301530
while (string.pointer != string.end)
@@ -1570,7 +1570,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
15701570
}
15711571
}
15721572

1573-
if (CHECK(string, '#') && preceeded_by_whitespace) {
1573+
if (CHECK(string, '#') && preceded_by_whitespace) {
15741574
flow_indicators = 1;
15751575
block_indicators = 1;
15761576
}
@@ -1619,7 +1619,7 @@ yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
16191619
previous_break = 0;
16201620
}
16211621

1622-
preceeded_by_whitespace = IS_BLANKZ(string);
1622+
preceded_by_whitespace = IS_BLANKZ(string);
16231623
MOVE(string);
16241624
if (string.pointer != string.end) {
16251625
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
@@ -1784,7 +1784,7 @@ yaml_emitter_write_indent(yaml_emitter_t *emitter)
17841784

17851785
static int
17861786
yaml_emitter_write_indicator(yaml_emitter_t *emitter,
1787-
const char *indicator, int need_whitespace,
1787+
char *indicator, int need_whitespace,
17881788
int is_whitespace, int is_indention)
17891789
{
17901790
size_t indicator_length;
@@ -2178,7 +2178,7 @@ yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter,
21782178
yaml_string_t string)
21792179
{
21802180
char indent_hint[2];
2181-
const char *chomp_hint = NULL;
2181+
char *chomp_hint = NULL;
21822182

21832183
if (IS_SPACE(string) || IS_BREAK(string))
21842184
{

0 commit comments

Comments
 (0)