Embedded resource files losing the null-terminator

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Ravana
Posts: 5
Joined: 2011-11-17T17:44:01-07:00
Authentication code: 8675308

Embedded resource files losing the null-terminator

Post by Ravana »

I found a bug when loading embedded xml resource files.

StringInfo->datum will later be passed to NewXMLTree() who expects it to be null-terminated.
StringToStringInfo() strips the trailing null, so instead do what ConfigureFileToStringInfo() does when loading from a file.

Code: Select all

Index: MagickCore/configure.c
===================================================================
--- MagickCore/configure.c	(revision 5993)
+++ MagickCore/configure.c	(working copy)
@@ -581,10 +581,11 @@
     blob=(char *) NTResourceToBlob(filename);
     if (blob != (char *) NULL)
       {
-        xml=StringToStringInfo(blob);
+        xml=AcquireStringInfo(0);
+        xml->length=strlen(blob)+1;
+        xml->datum=(unsigned char *) blob;
         SetStringInfoPath(xml,filename);
         (void) AppendValueToLinkedList(options,xml);
-        blob=DestroyString(blob);
       }
   }
 #endif
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Embedded resource files losing the null-terminator

Post by magick »

Thanks for the bug report and patch. We'll get the patch into the next point release of ImageMagick.
Post Reply