json 2.15.2 → 2.15.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b883349b3a8a8c1ccb003e74779a577e3a16e8c3d8541693fb477a78aeac3a68
4
- data.tar.gz: efb11cf9e69ece0ebb11d33aec23401b0c1ed1d7a39c351f82998ba82cbd47b8
3
+ metadata.gz: e0a73f62257d521165faeb372eafe66beb01fe47b4790256840f4316aa762510
4
+ data.tar.gz: 135d0b30fd72cd54b91b84050fe86a67b1aaf909f2024f5a545288cfbe3a2088
5
5
  SHA512:
6
- metadata.gz: f78e23c6bd8b8dcddaaf051d6ae60253fd6c96e108395b475d825d9daf3fba4f754f280ae095f456ee67917dd991c8477caa86038f378f23d49e17744467cb7a
7
- data.tar.gz: 64946a58a223efb1e333ff15eba3776d44505cfb78ba0102350177b6351f4643107db5f37ddb65c41569b4d58b5147176c8043b182abd152c74c63351be958fd
6
+ metadata.gz: d51c8d7de86d2581845d73638053da3f7c5aea014da4a960630fd78bba234647e37b301dec74f93069cc584d7f2495a394dc4a5d5514f543dee195413a863ebf
7
+ data.tar.gz: 3a871434b7427979f6c860e7ec33772ff61ddd0d272ac40de51fc887a14f50e65653d70b8276b2b535870a20801d7e6c2068b6f5bfb68293fc0e0de3a82aa729
data/CHANGES.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### Unreleased
4
4
 
5
+ ### 2026-03-18 (2.15.2.1)
6
+
7
+ * Fix a format string injection vulnerability in JSON.parse(doc, allow_duplicate_key: false).
8
+
5
9
  ### 2025-10-25 (2.15.2)
6
10
 
7
11
  * Fix `JSON::Coder` to have one dedicated depth counter per invocation.
@@ -428,14 +428,9 @@ static void emit_parse_warning(const char *message, JSON_ParserState *state)
428
428
 
429
429
  #define PARSE_ERROR_FRAGMENT_LEN 32
430
430
 
431
- #ifdef RBIMPL_ATTR_NORETURN
432
- RBIMPL_ATTR_NORETURN()
433
- #endif
434
- static void raise_parse_error(const char *format, JSON_ParserState *state)
431
+ static VALUE build_parse_error_message(const char *format, JSON_ParserState *state, long line, long column)
435
432
  {
436
433
  unsigned char buffer[PARSE_ERROR_FRAGMENT_LEN + 3];
437
- long line, column;
438
- cursor_position(state, &line, &column);
439
434
 
440
435
  const char *ptr = "EOF";
441
436
  if (state->cursor && state->cursor < state->end) {
@@ -470,11 +465,23 @@ static void raise_parse_error(const char *format, JSON_ParserState *state)
470
465
  VALUE msg = rb_sprintf(format, ptr);
471
466
  VALUE message = rb_enc_sprintf(enc_utf8, "%s at line %ld column %ld", RSTRING_PTR(msg), line, column);
472
467
  RB_GC_GUARD(msg);
468
+ return message;
469
+ }
473
470
 
471
+ static VALUE parse_error_new(VALUE message, long line, long column)
472
+ {
474
473
  VALUE exc = rb_exc_new_str(rb_path2class("JSON::ParserError"), message);
475
474
  rb_ivar_set(exc, rb_intern("@line"), LONG2NUM(line));
476
475
  rb_ivar_set(exc, rb_intern("@column"), LONG2NUM(column));
477
- rb_exc_raise(exc);
476
+ return exc;
477
+ }
478
+
479
+ NORETURN(static) void raise_parse_error(const char *format, JSON_ParserState *state)
480
+ {
481
+ long line, column;
482
+ cursor_position(state, &line, &column);
483
+ VALUE message = build_parse_error_message(format, state, line, column);
484
+ rb_exc_raise(parse_error_new(message, line, column));
478
485
  }
479
486
 
480
487
  #ifdef RBIMPL_ATTR_NORETURN
@@ -875,6 +882,11 @@ static void raise_duplicate_key_error(JSON_ParserState *state, VALUE duplicate_k
875
882
  rb_inspect(duplicate_key)
876
883
  );
877
884
 
885
+ long line, column;
886
+ cursor_position(state, &line, &column);
887
+ rb_str_concat(message, build_parse_error_message("", state, line, column)) ;
888
+ rb_exc_raise(parse_error_new(message, line, column));
889
+
878
890
  raise_parse_error(RSTRING_PTR(message), state);
879
891
  RB_GC_GUARD(message);
880
892
  }
data/lib/json/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSON
4
- VERSION = '2.15.2'
4
+ VERSION = '2.15.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.15.2
4
+ version: 2.15.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
- rubygems_version: 3.6.9
85
+ rubygems_version: 4.0.3
86
86
  specification_version: 4
87
87
  summary: JSON Implementation for Ruby
88
88
  test_files: []