json 2.19.1 → 2.19.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: 04f1d3824b8119f86068d5c61701115a38fd9b0b37e59fb868baca59cb49fe6c
4
- data.tar.gz: f9267f5bf2c12bd5762878b31873052b85022354da9dc347d06f05fa0dd2f5e6
3
+ metadata.gz: 747237eb2b9348d361e6e93684f81381b4f0dcf0cd36971bc809ac042ce295bc
4
+ data.tar.gz: 1c6243010258fd2077acf63c5b372babce9a32e789630279bc8b129fc2deef5d
5
5
  SHA512:
6
- metadata.gz: 03777fe540a81fa223ca8990d4f9128d97ad57e795fda888ad8a8914208ed5950b1c49d90488a58827d252245d624953750142578b13eacfb82843fd17fb409e
7
- data.tar.gz: 747625c3e441fe66d20710b4029b0b650e54e60313700d3c849b306c1ce2fac7a94dc9471962ccccea0a64031499adae59270149b4f70ed64795f269939fb6c5
6
+ metadata.gz: b43b4ca3d570a3c4051a319f9eb2d2807a6b2567f43cedf8bc21d8208289a3f3a275dc650353cd6ef4bd3e2022afcf73f17164fda51081134e11ac5172374459
7
+ data.tar.gz: 82a96b04fa36bb5b0ab72868d67e95cfcc8cc8d3f0a045a1caf8045b090e5cf46647b664accf7c657073020847cd8ce6ad28535d14536e214dcaab21b6aa4c17
data/CHANGES.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### Unreleased
4
4
 
5
+ ### 2026-03-08 (2.19.2)
6
+
7
+ * Fix a format string injection vulnerability in `JSON.parse(doc, allow_duplicate_key: false)`.
8
+
5
9
  ### 2026-03-08 (2.19.1)
6
10
 
7
11
  * Fix a compiler dependent GC bug introduced in `2.18.0`.
@@ -402,11 +402,9 @@ static void emit_parse_warning(const char *message, JSON_ParserState *state)
402
402
 
403
403
  #define PARSE_ERROR_FRAGMENT_LEN 32
404
404
 
405
- NORETURN(static) void raise_parse_error(const char *format, JSON_ParserState *state)
405
+ static VALUE build_parse_error_message(const char *format, JSON_ParserState *state, long line, long column)
406
406
  {
407
407
  unsigned char buffer[PARSE_ERROR_FRAGMENT_LEN + 3];
408
- long line, column;
409
- cursor_position(state, &line, &column);
410
408
 
411
409
  const char *ptr = "EOF";
412
410
  if (state->cursor && state->cursor < state->end) {
@@ -441,11 +439,23 @@ NORETURN(static) void raise_parse_error(const char *format, JSON_ParserState *st
441
439
  VALUE msg = rb_sprintf(format, ptr);
442
440
  VALUE message = rb_enc_sprintf(enc_utf8, "%s at line %ld column %ld", RSTRING_PTR(msg), line, column);
443
441
  RB_GC_GUARD(msg);
442
+ return message;
443
+ }
444
444
 
445
+ static VALUE parse_error_new(VALUE message, long line, long column)
446
+ {
445
447
  VALUE exc = rb_exc_new_str(rb_path2class("JSON::ParserError"), message);
446
448
  rb_ivar_set(exc, rb_intern("@line"), LONG2NUM(line));
447
449
  rb_ivar_set(exc, rb_intern("@column"), LONG2NUM(column));
448
- rb_exc_raise(exc);
450
+ return exc;
451
+ }
452
+
453
+ NORETURN(static) void raise_parse_error(const char *format, JSON_ParserState *state)
454
+ {
455
+ long line, column;
456
+ cursor_position(state, &line, &column);
457
+ VALUE message = build_parse_error_message(format, state, line, column);
458
+ rb_exc_raise(parse_error_new(message, line, column));
449
459
  }
450
460
 
451
461
  NORETURN(static) void raise_parse_error_at(const char *format, JSON_ParserState *state, const char *at)
@@ -895,6 +905,11 @@ NORETURN(static) void raise_duplicate_key_error(JSON_ParserState *state, VALUE d
895
905
  rb_inspect(duplicate_key)
896
906
  );
897
907
 
908
+ long line, column;
909
+ cursor_position(state, &line, &column);
910
+ rb_str_concat(message, build_parse_error_message("", state, line, column)) ;
911
+ rb_exc_raise(parse_error_new(message, line, column));
912
+
898
913
  raise_parse_error(RSTRING_PTR(message), state);
899
914
  RB_GC_GUARD(message);
900
915
  }
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.19.1'
4
+ VERSION = '2.19.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.19.1
4
+ version: 2.19.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank