Problem with Perl script and image maps

Lowell Filak lfilak at MEDINACO.ORG
Tue Aug 30 21:48:22 EDT 2005


The following message was sent by Rob Parsons
<rparsons at TAPPUBLISHING.COM> on Tue, 30 Aug 2005 20:05:34 -0500.

> In case anyone is interested, I did solve this mystery.
> 
> After spending a couple of hours with gdb and examining the source, I
> tracked the Segmentation fault down to a realloc() instruction in the
> im_iprintf() function located in the mapimagemap.c file. This function
> appends new output onto the original string, allocating memory as
> necessary to accommodate the growth of the output. The SIGSEGV was
> occuring when memory needed to be reallocated, indicating that something
> was writing into non-allocated space.
> 
> The source contains a compiler directive that checks for a #DEFINE that
> indicates the availability of a vsnprintf() command on the local platform.
> If it's not available, then the vsprintf() command is used instead. The
> difference between these two commands is that vsnprintf() has a safety
> stop that will end processing at a given number of bytes. vsprintf() has
> no such mechanism. It took me a while to find because I knew that my
> Debian Linux platform had vsnprintf(). Unfortunately, the
> Mapserver 'configure' script does not seem to contain a way to properly
> detect vsnprintf() and therefore the vsprintf() command was being used
> instead. This command has no safety stop and there was nothing in the code
> to prevent it from writing a few bytes past the end of allocated memory.
> In this state, executing this code on any platform that doesn't have
> vsprintf() will result in SIGSEGVs at best and corrupted memory at worst.
> 
> This problem affects not only Mapscript code, but SHP2IMG and others as
> well. Fortunately there is an easy fix. If you know for sure that your
> platform has vsnprintf() available, then you can SET and EXPORT "CFLAGS=-
> DHAVE_VSNPRINTF" before invoking the 'configure' script. Alternately, or
> if you don't know whether vsnprintf() is available, you can edit the
> configure.in file and add the following line in the appropriate place:
> 
> AC_CHECK_FUNC(vsnprintf,      STRINGS="-DHAVE_VSNPRINTF $STRINGS")
> 
> After editing the file, run the autoconf utility to build a
> new 'configure' script. Either of those solutions should fix this problem
> on affected platforms.

Rob,

I beleive this needs to be filed as a bug.
Can you add this to bugzilla?

Lowell



More information about the mapserver-users mailing list