json 2.17.1 → 2.17.1.2

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: e803f3f9e7d45dba43221559016a34d8cc9e3ab491e39137d17b614713edb710
4
- data.tar.gz: 429e3465eada0c9d985c94dbd13bbdd8d57e4b62cf7cf06273f22e136dafb4a8
3
+ metadata.gz: 6a9a3645975d3e5df1aee69354bb7cefe81940009e677758de0f52617e82e871
4
+ data.tar.gz: 4dfdd1d03081d3a714798c7f9ac89d58285b9d6f7aa82edd430d6118120faad2
5
5
  SHA512:
6
- metadata.gz: adebc7ed56efc6651e23730720ea9f365e434ae234d70620469ae3e8a9240ada46f0ce7d6982f30a1301104fd2b033eaac57950c2657cfc5b2e7b79ffe73a925
7
- data.tar.gz: 346c97276881d404414359ce0893fd16fe35d6413377b4ad3d71448a9f5fb919a61ef7630fc186a6aeef11fa6422273d0625eccfdd6a57a00c98c0e470c7ec92
6
+ metadata.gz: 85cce8ba1edd888d298eebf4279c3381dbbe103b48f59a998db05026028b388317c39fc3c306d32f3e0ada010f0cdff42c978c1173b0af90c93e42d16e78246f
7
+ data.tar.gz: 8dd8ecf39713290c9fbaf0d1d574636e7c8392252edd7accd4fb2d0bf679f7eeb89efdd099e3d20a57df91ff96bf7bf0b30338d71a22f7cf666799713a3dd3e3
data/CHANGES.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### Unreleased
4
4
 
5
+ ### 2026-03-18 (2.17.1.2)
6
+
7
+ * Fix a format string injection vulnerability in JSON.parse(doc, allow_duplicate_key: false).
8
+
5
9
  ### 2025-12-04 (2.17.1)
6
10
 
7
11
  * Fix a regression in parsing of unicode surogate pairs (`\uXX\uXX`) that could cause an invalid string to be returned.
@@ -399,14 +399,9 @@ static void emit_parse_warning(const char *message, JSON_ParserState *state)
399
399
 
400
400
  #define PARSE_ERROR_FRAGMENT_LEN 32
401
401
 
402
- #ifdef RBIMPL_ATTR_NORETURN
403
- RBIMPL_ATTR_NORETURN()
404
- #endif
405
- static void raise_parse_error(const char *format, JSON_ParserState *state)
402
+ static VALUE build_parse_error_message(const char *format, JSON_ParserState *state, long line, long column)
406
403
  {
407
404
  unsigned char buffer[PARSE_ERROR_FRAGMENT_LEN + 3];
408
- long line, column;
409
- cursor_position(state, &line, &column);
410
405
 
411
406
  const char *ptr = "EOF";
412
407
  if (state->cursor && state->cursor < state->end) {
@@ -441,11 +436,23 @@ static void raise_parse_error(const char *format, JSON_ParserState *state)
441
436
  VALUE msg = rb_sprintf(format, ptr);
442
437
  VALUE message = rb_enc_sprintf(enc_utf8, "%s at line %ld column %ld", RSTRING_PTR(msg), line, column);
443
438
  RB_GC_GUARD(msg);
439
+ return message;
440
+ }
444
441
 
442
+ static VALUE parse_error_new(VALUE message, long line, long column)
443
+ {
445
444
  VALUE exc = rb_exc_new_str(rb_path2class("JSON::ParserError"), message);
446
445
  rb_ivar_set(exc, rb_intern("@line"), LONG2NUM(line));
447
446
  rb_ivar_set(exc, rb_intern("@column"), LONG2NUM(column));
448
- rb_exc_raise(exc);
447
+ return exc;
448
+ }
449
+
450
+ NORETURN(static) void raise_parse_error(const char *format, JSON_ParserState *state)
451
+ {
452
+ long line, column;
453
+ cursor_position(state, &line, &column);
454
+ VALUE message = build_parse_error_message(format, state, line, column);
455
+ rb_exc_raise(parse_error_new(message, line, column));
449
456
  }
450
457
 
451
458
  #ifdef RBIMPL_ATTR_NORETURN
@@ -889,6 +896,11 @@ static void raise_duplicate_key_error(JSON_ParserState *state, VALUE duplicate_k
889
896
  rb_inspect(duplicate_key)
890
897
  );
891
898
 
899
+ long line, column;
900
+ cursor_position(state, &line, &column);
901
+ rb_str_concat(message, build_parse_error_message("", state, line, column)) ;
902
+ rb_exc_raise(parse_error_new(message, line, column));
903
+
892
904
  raise_parse_error(RSTRING_PTR(message), state);
893
905
  RB_GC_GUARD(message);
894
906
  }
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.17.1'
4
+ VERSION = '2.17.1.2'
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.17.1
4
+ version: 2.17.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.6.9
87
+ rubygems_version: 4.0.3
88
88
  specification_version: 4
89
89
  summary: JSON Implementation for Ruby
90
90
  test_files: []