Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
rubygem-nokogiri.26619
004_CVE-2022-29181.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 004_CVE-2022-29181.patch of Package rubygem-nokogiri.26619
commit 83cc451c3f29df397caa890afc3b714eae6ab8f7 Author: Mike Dalessio <mike.dalessio@gmail.com> Date: Fri May 6 21:57:41 2022 -0400 fix: {HTML4,XML}::SAX::{Parser,ParserContext} check arg types Previously, arguments of the wrong type might cause segfault on CRuby. --- a/ext/nokogiri/html_sax_parser_context.c 2022-10-27 13:54:37.249029870 +0200 +++ b/ext/nokogiri/html_sax_parser_context.c 2022-10-27 14:12:29.654049001 +0200 @@ -18,8 +18,8 @@ { htmlParserCtxtPtr ctxt; - if (NIL_P(data)) - rb_raise(rb_eArgError, "data cannot be nil"); + Check_Type(data, T_STRING); + if (!(int)RSTRING_LEN(data)) rb_raise(rb_eRuntimeError, "data cannot be empty"); --- a/lib/nokogiri/html/sax/parser.rb 2022-10-27 13:54:37.257029908 +0200 +++ b/lib/nokogiri/html/sax/parser.rb 2022-10-27 14:29:09.358588792 +0200 @@ -29,7 +29,7 @@ ### # Parse html stored in +data+ using +encoding+ def parse_memory data, encoding = 'UTF-8' - raise ArgumentError unless data + raise TypeError unless String === data return unless data.length > 0 ctx = ParserContext.memory(data, encoding) yield ctx if block_given? } --- a/ext/nokogiri/xml_sax_parser_context.c 2022-10-27 20:36:11.589081572 +0200 +++ b/ext/nokogiri/xml_sax_parser_context.c 2022-10-27 20:39:01.637884585 +0200 @@ -2,6 +2,8 @@ VALUE cNokogiriXmlSaxParserContext ; +static ID id_read; + static void deallocate(xmlParserCtxtPtr ctxt) { NOKOGIRI_DEBUG_START(handler); @@ -25,6 +27,10 @@ xmlParserCtxtPtr ctxt; xmlCharEncoding enc = (xmlCharEncoding)NUM2INT(encoding); + if (!rb_respond_to(io, id_read)) { + rb_raise(rb_eTypeError, "argument expected to respond to :read"); + } + ctxt = xmlCreateIOParserCtxt(NULL, NULL, (xmlInputReadCallback)io_read_callback, (xmlInputCloseCallback)io_close_callback, @@ -60,8 +66,8 @@ { xmlParserCtxtPtr ctxt; - if (NIL_P(data)) - rb_raise(rb_eArgError, "data cannot be nil"); + Check_Type(data, T_STRING); + if (!(int)RSTRING_LEN(data)) rb_raise(rb_eRuntimeError, "data cannot be empty"); @@ -219,4 +225,6 @@ rb_define_method(klass, "replace_entities", get_replace_entities, 0); rb_define_method(klass, "line", line, 0); rb_define_method(klass, "column", column, 0); + + id_read = rb_intern("read"); }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor