[PATCH] Fix FilenameTruncated check in ExpandFilenames
Posted: 2010-05-02T20:13:24-07:00
The mailing list seems to be dead, so posting this here.
On topic: I found the @filelist.txt feature useful for getting around the command-line length limitation on Windows (8191 characters). However, the "filename length" limitation (directly related to the patch above) means that I can't put a very long -draw command in a file. Of course, the simple workaround is to break up the long -draw command into multiple -draw commands. It'd be nice getting rid of that limitation, anyway (it doesn't exist for command-line parameters on systems where the total command-line length isn't an issue, after all).
Edit: looks like the workaround wasn't as simple as splitting up the -draw command-strings - draw settings are lost from one -draw to another.
Code: Select all
This patch fixes a check that would otherwise always have evaluated to
"false". Since ConcatenateMagickString will never create a string the
strlen of which to be greater or equal than the specified maximum length
(due to the null terminator), ExpandFilenames always truncated filenames
silently.
---
magick/utility.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/magick/utility.c b/magick/utility.c
index 62c8006..58a9bbb 100644
--- a/magick/utility.c
+++ b/magick/utility.c
@@ -810,31 +810,31 @@ MagickExport MagickBooleanType ExpandFilenames(int *number_arguments,
/*
Transfer file list to argument vector.
*/
vector=(char **) ResizeQuantumMemory(vector,(size_t) *number_arguments+
count+number_files+1,sizeof(*vector));
if (vector == (char **) NULL)
return(MagickFalse);
for (j=0; j < (long) number_files; j++)
{
(void) CopyMagickString(filename,path,MaxTextExtent);
if (*path != '\0')
(void) ConcatenateMagickString(filename,DirectorySeparator,
MaxTextExtent);
(void) ConcatenateMagickString(filename,filelist[j],MaxTextExtent);
filelist[j]=DestroyString(filelist[j]);
- if (strlen(filename) >= MaxTextExtent)
+ if (strlen(filename) >= MaxTextExtent-1)
ThrowFatalException(OptionFatalError,"FilenameTruncated");
if (IsPathDirectory(filename) <= 0)
{
char
path[MaxTextExtent];
*path='\0';
if (*magick != '\0')
{
(void) ConcatenateMagickString(path,magick,MaxTextExtent);
(void) ConcatenateMagickString(path,":",MaxTextExtent);
}
(void) ConcatenateMagickString(path,filename,MaxTextExtent);
if (*subimage != '\0')
{
--
1.7.0.2.msysgit.1.891.gee59bc
Edit: looks like the workaround wasn't as simple as splitting up the -draw command-strings - draw settings are lost from one -draw to another.