Thanks for merging! Am 05.12.2022 11:43, schrieb Matthieu Labas: Nice (sort of ;))! I've applied the patch to create the v4.5.4. Thanks! [bugs:#29] [1] Fix for memory leak in sxmlc.c Status: open Group: v4.3.4 Created: Sun Dec 04, 2022 05:38 PM UTC by Joerg Bakker Last Updated: Sun Dec 04, 2022 05:38 PM UTC Owner: Matthieu Labas Attachments: sxmlc_memleak.patch [2] (1.4 kB; text/x-patch) The attached patch fixes a memory leak in sxmlc.c Sent from sourceforge.net because you indicated interest in...
Fix for memory leak in sxmlc.c
Nice (sort of ;))! I've applied the patch to create the v4.5.4. Thanks!
*** v4.5.4 - Corrected memory leak if text contained HTML-escaped characters (thanks @hakker_de!).
Fix for memory leak in sxmlc.c
*** v4.5.3 - Corrected write on NULL for not-XML files (thanks @bladchan!).
fix memory size to store safely the '\0' after the string
*** v4.5.2 - Corrected buffer overrun on unhtml() (thanks @gvollant!).
Merge pull request #23 from gvollant/bugfix/crash_memory
Merge pull request #21 from jeaeberle/feature/cmake
Improved CMake support
Added cmake support
Merge pull request #20 from raldone01/master
Haha awesome. I do follow your project on github already, in fact, we exchanged some words on past years, I had another pseudonym (IgorJorobus), we fixed a few things. Thanks for the good vibes, have a good day! D.
Awesome, thanks Damian! It feels really rewarding to see that this small project is actually helping people develop bigger things :) I checked out your xlsx_drone project, it seems to be something I could be working with. I especially love the very few files it needs (I guess you noticed it from sxmlc as well ;)). Also, although sxmlc staerted on SourceForge, it is on GitHub as well, in case it's easier to link to: https://github.com/matthieu-labas/sxmlc Thanks again for letting me know, I hope you...
Hello Matthieu, I've given you credit and thanks for your library, which was used for my project xlsx_drone. Be free to check it out: https://github.com/damian-m-g/xlsx_drone I'll increase the use of sxmlc when I provide writting functionality to xlsx. Cheers & thanks, D.
Thank Damian for the update. The UTF-8 part was extensively tested by "hundreds of (external) tests" (from what I was told) so I should be confident that it should be working fine, but you how bugs like to nest in the most hidden places ;) Happy New Year! :) Matthieu
Happy New Year! :)
Thank Damian for the update. The UTF-8 part was extensively tested by "hundredth of (external) tests" (from what I was told) so I should be confident that it should be working fine, but you how bugs like to nest in the most hidden places ;) Happy New Year! :) Matthieu
Hi Matthieu, Thanks for the quick answer. I was dealing with this issue since 2 days ago, it happened to be a bug in my C code that caused the segfault. As cross-language debugging isn't possible, I wasn't able to debug the C code where things failed. So today I started dropping some printf() to track the problem and found out a bug in my code. After fixing that, everything works good. I'm able to use all my functions, and to instruct Ruby to take those strings as UTF-8. So I would say, for anyone...
Hello Damian, The difference when compiling with SXMLC_UNICODE is that the file (if you're parsing files, not buffers) is opened in binary mode (fopen("rb")) and all string functions (strdup(), strlen(), etc.) assume wide char instead of char. So maybe if there are characters that must be stored on more than one byte, it could overflow some buffer. We can consider the following: multi-byte characters are never null (see https://unicodebook.readthedocs.io/unicode_encodings.html) so non-SXMLC_UNICODE...
Hello Matthieu, I'm working with utf-8 xml files without bom without using the SXMLC_UNICODE features and everything seems to work great, my test assertions with utf-8 strings works okay. Even that, I'm having issues when calling a C function that sets utf-8 strings with a FFI, binding to Ruby. When I call it to set ASCII strings works great, but when UTF-8 is involved, the call to that function triggers a Segfault error. My question is: do I must include support for unicode (-DSXMLC_UNICODE) even...
v4.5.1 - Added missing free() in XMLSearch_free() (thanks @yogibe4r!).
*** v4.5.0 - HTML decoding on node text.
*** v4.4.0 - Added UTF-8 support (many thanks to Todd Osborne!).
First step of including Todd Osborne's UTF8 fixes (UTF8 support without SXMLC_UNICODE #define):
Empty XML file causing segmentation fault
OK thanks. I changed the macro to check for the i_root validity and retur NULL if < 0. I pushed the changes to v4.3.4.
*** v4.3.4 - Test for i_root validity in macro XMLDoc_root.
Hi Matthieu, Excuse me for delayed reply I am using the VERSION "4.3.3" The error appeared in the line node = XMLDoc_root(&doc); this error caused by reading empty xml file
Empty XML file causing segmentation fault
Hi ElOualid, Thank you for the report. However I can't find such reference in the code. Can you tell me which version you're using and which file and line number you got the error? Thanks! Matthieu
Empty XML file causing segmentation fault
Expose data source context to user
Added in v4.3.3.
*** v4.3.3 - Added Sourceforge#12 by Alexander Goomenyuk (expose data source context to user).
OK, I think I get it: the entity reading the XML file is not aware about the XML structure and needs to know the offset and length to read the proper data. I will add your patch in the next version, hopefully this week. Thanks!
OK, I think I get it: the entity reading the XML file is not aware about the XML structure and needs to know the offset and length. I will add your patch in the next version, hopefully this week. Thanks!
Thanks for reply! Here is real life example: There are two exchangeable units: a flange board and add-on equipment. There is EEPROM on add-on equipment which stores some parameters of attached add-on in XML format. The add-on is attached to flange board. The firmware running on that board reads EEPROM, extracts XML file and parse it. Two XML-tags are searched for during the parsing. First tag defines begining of configuration parameters and second tag specifies the name of configuration parameters...
Hi Alexander, I'm not sure I understand what is your need. Could you give me an example (if possible) so I can see if there are some other ways around? Thank you for the patch anyway, adding those information might be interesting anyway! Regards, Matthieu
Expose data source context to user
Correction of CHECK_NODE macro that returned false on valid nodes!
*** v4.3.2 - Fixed GitHub#11 by Damián M. González (missing free() on XMLNode_set_text()).
Non-recursive doxumentation (all files are in the same directory anyway...).
Do not doxument test files.
*** v4.3.1 - Correction on XMLNode_get_index().
*** v4.3.0 - Added Github#9: "Support for XMLNode_add_sibling()".
Ease node creation
Done in v4.2.7
Add sx_puts, sx_fputs
Remove unused printf data arguments
Merge pull request #8 from sometimesfood/add-fputs
Fix _getch define in test.c for non-Linux Unices
Merge pull request #7 from sometimesfood/fix-warnings
Add const cast
error reporting by the parser
Fixed in v4.2.10. Though parser will not report an error on unfinished root tags. At the moment it should be considered a warning: SAX will stop parsing and the caller should check that open nodes were not finished; DOM will just leave nodes as they are (i.e. no new nodes are added to the "unfinished" nodes, though there are no way to know they were not finished).
Buffer overflow issue in read_line_alloc at src/sxmlc.c:1841
Fixed in v4.2.10.
*** v4.2.10 - Fixed #27: report error when < or > is in attribute value.
Buffer overflow issue in read_line_alloc at src/sxmlc.c:1841
crash2.html is not a human-readable file because crash2.html is generated by our automated test generation tool FOCAL, not a human developer. A malicious attacker can use a such unexpected file (human readable or not) to cause a crash and exploit this crash as a security vulnerability. Thus, I think that this bug can cause a serious security problem and should be fixed. Thank you
Forgot the version (again...).
error reporting by the parser
This is (somehow) expected behaviour: sxmlc was designed to handle multiple root nodes, so both xml1 and xml2 are showing two root nodes. However, one of them is not finished so a warning could be raised. I'll prepare a feature request on that. The error reported in xml3 was expected as I remember I read in some specs that > was legal in XML attribute values. However, I can't find that anymore, but could find several links showing it was illegal. As I want sxmlc to be as permissive as possible (i.e....
error reporting by the parser
*** v4.2.9 - Fixed potential buffer overflow in strip_spaces() (#24).
*** v4.2.9 - Fixed commit.
Changed Eclipse to Photo.
Infinite Loop in XMLDoc_parse_buffer_DOM_text_as_nodes()
XMLDoc_parse_file_DOM do not return false after finding ERROR
Behaviour was changed so that 0 is returned on parsing when a SAX callback returns 0.
Buffer overflow in strip_spaces src/sxmlc.c:1916
Will be delivered in v4.2.9.
XMLDoc_parse_file_DOM do not return false after finding ERROR
I can't read the crash2.html. Can you try to attach it again? Or copy-paste it in a comment? Thanks!
Buffer overflow issue in read_line_alloc at src/sxmlc.c:1841
Buffer overflow in strip_spaces src/sxmlc.c:1916
There is indeed a problem in strip_spaces() when the str argument is only spaces (i.e. isspace() returns non-0).
Buffer overflow issue in read_line_alloc at src/sxmlc.c:1841
Buffer overflow in strip_spaces src/sxmlc.c:1916
XMLDoc_parse_buffer_DOM bug
v4.2.8 delivered.
Added macros to ease node creations, comments, ...
*** v4.2.8 - Added buffer length to buffer parsing (#23).
Hi Matthieu, yesterday evening I detect the problem by debugging. I solve it by using a calloc instead of malloc, so that the buffer is already well terminated. So we are reaching the same problem. Thanks, Ermanno
(which means I suspect the buffer you're parsing is just enough to contain the whole XML and is not null-terminated. Removing a character somewhere will make room for the null termination and make things work)