Menu

#3 Rapid XML 1.12 doesn't handle zero-length strings correctly

open
nobody
None
5
2009-03-03
2009-03-03
Anonymous
No

Rapid XML 1.12 interprets a zero, when specified as a string's length, as indicating that the string is a C-string & its length should be calculated appropriately.
This makes it difficult to add variable length data where it may have zero length, but isn't necessarily a C-string. This may have also introduced hidden bugs into users code. Zero is a valid length for data & should be interpreted literally.

The attached patch defines a new constant `auto_size` to use instead of `0` and modifies code appropriately. Note: The change was sufficient for my usage. It probably requires some further work to update every occurrence.

Discussion

  • Nobody/Anonymous

    Initial patch to handle zero-length strings

     
  • Nobody/Anonymous

    This is a significant problem. Take, for instance, a routine which is designed to copy an arbitrary XML tree to a different document. To support both destructively-parsed and non-destructively-parsed trees, and for efficiency, such a routine will need to call allocate_string() with a length parameter. But if the source tree contains strings with zero length that are not NULL terminated, all hell will break loose.

     

Log in to post a comment.