Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abort for an invalid xml file #16

Open
chowisely opened this issue Jan 3, 2020 · 1 comment
Open

abort for an invalid xml file #16

chowisely opened this issue Jan 3, 2020 · 1 comment

Comments

@chowisely
Copy link

chowisely commented Jan 3, 2020

Hi, I found that xml2json (commit d3a3d98) crashes with the attached XML file (test.txt) (Since Github doesn't support xml file, I attached txt file instead.) which has syntax errors. The crash was observed on Ubuntu 18.04.3 with kernel 4.15.0-72-generic and x86_64. The crash can be reproduced by the following command:

Here’s the crash stack trace by GDB:

#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007ffff7483801 in __GI_abort () at abort.c:79
#2 0x00007ffff7ad8957 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff7adeab6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff7adeaf1 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff7aded24 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x0000555555585a70 in rapidxml::xml_document::parse<0> () at ./include/rapidxml/rapidxml.hpp:1628
#7 xml2json[abi:cxx11](char const*) () at ./include/xml2json.hpp:248
#8 0x0000555555587e5b in convert (input=...) at xml2json.cpp:14
#9 0x00005555555568d8 in main () at xml2json.cpp:23

It was found by the AFL fuzzer with the xml samples in the test directory as seeds.
Hope this help.

@javadev
Copy link

javadev commented Mar 29, 2021

<tl attr="added attr"> 
  <nuode_without_attr/>
  <id tid="added tid">1234567890a</id>  
  <ts>
  	teplextext2 makes it more complex array
  	<text_array>text</text_array>
  	<text_array>text</text_array>
  	text3
    <lang lage="Chinese">1</lang>
    <![CDATA[hen the cdata is good.]]>
    <nnode_again_inside/>
<t>
ke it more complex
      <st>26.026</st> <du>3.993</du> <ct>жґѕжёж‘„制&amp;test</ct> 
    </t>   <t> 
  <st>48.048</st> <du>3.993</du> <ct>主演:詹姆斯.史都华</ct> 
    </t>   <t> 
  <st>60.060</st> <du>3.993</du> <ct>主演:金.诺娃</ct>  </t>  
 </ts>
</tl>

may be converted to json

{
   "tl": {
      "-attr": "added attr",
      "nuode_without_attr": {
         "-self-closing": "true"
      },
      "id": {
         "-tid": "added tid",
         "#text": "1234567890a"
      },
      "ts": {
         "#text": "\n  \tteplextext2 makes it more complex array\n  \t",
         "text_array": [
            "text",
            "text"
         ],
         "#text1": "\n  \ttext3\n    ",
         "lang": {
            "-lage": "Chinese",
            "#text": "1"
         },
         "#cdata-section": "hen the cdata is good.",
         "nnode_again_inside": {
            "-self-closing": "true"
         },
         "t": [
            {
               "#text": "\nke it more complex\n      ",
               "st": "26.026",
               "du": "3.993",
               "ct": "жґѕжёж\u2018\u201E制&test"
            },
            {
               "st": "48.048",
               "du": "3.993",
               "ct": "дё»жј\u201Dпјљи©№е§\u2020ж\u2013Ї.еЏІйѓЅеЌЋ"
            },
            {
               "st": "60.060",
               "du": "3.993",
               "ct": "дё»жј\u201Dпјљй\u2021\u2018.иЇєеЁѓ"
            }
         ]
      }
   },
   "#omit-xml-declaration": "yes"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants