[mapserver-users] Oddball mapserver/ArcSDE issue

Paul Ramsey pramsey at cleverelephant.ca
Thu Mar 18 14:33:13 EDT 2010


Russell,
Attach your patch to a ticket (http://trac.osgeo.org/mapserver) and
assign it to me (pramsey) and I'll ensure it's committed into the next
patch releases and major releases.
P

On Thu, Mar 18, 2010 at 11:03 AM, Russell McOrmond <russell at flora.ca> wrote:
>
> On Tue, 16 Mar 2010, Russell McOrmond wrote:
>
>>  The segmentation fault is caused by using a string which is actually null
>> being returned from string functions, with the null then being used as if it
>> were a string.
>>  See: http://trac.osgeo.org/mapserver/ticket/2988  "Check error returns
>> from mapstring functions."
>
>  Sorry to be responding to my own messages, but wanted to report on
> progress.
>
>
>  I added in some additional error return checking, and put some suggestions
> into the bug listed above.
>
>  I created some additional error reporting on what the reason for the
> iconv() failure was (see path at end of message), and now I see "An invalid
> multibyte sequence has been encountered in the input" in the MS_ERRORFILE.
>
>  While it is great to have mapserver not core dumping, I am still wondering
> if anyone has ideas of where to go next.  I suspect there is something
> invalid in the data that is causing ArcSDE to send me strings that aren't
> valid UTF-16 characters.  I don't know enough about ArcSDE or other ESRI
> software to know how to validate such things.
>
>
>
> Note: Please consider patches like the one below and/or the ones in the bug
> for future releases of mapserver.  It would be great if Mapserver would
> output error messages rather than core dump.
>
>
> --- mapstring.c-orig    2010-03-17 16:43:19.000000000 -0400
> +++ mapstring.c 2010-03-18 11:54:02.000000000 -0400
> @@ -1504,8 +1504,8 @@
>  char* msConvertWideStringToUTF8 (const wchar_t* string, const char*
> encoding) {
>  #ifdef USE_ICONV
>
> -    int bconvFailed = MS_TRUE;
>     char* output = NULL;
> +    char* errormessage = NULL;
>     iconv_t cd = NULL;
>     size_t nStr;
>     size_t nInSize;
> @@ -1540,23 +1540,36 @@
>            pszUTF8 = output;
>            pwszWide = string;
>            nConv = iconv(cd, (char **)&pwszWide, &nInSize, &pszUTF8,
> &nOutSize);
> -           if ((size_t)-1 != nConv &&  nOutSize != nBufferSize)
> -               bconvFailed = MS_FALSE;
> +           if ((size_t)-1 != nConv &&  nOutSize != nBufferSize) {
> +            switch (errno) {
> +              case E2BIG:
> +                errormessage = "There is not sufficient room in buffer";
> +                break;
> +              case EILSEQ:
> +                errormessage = "An invalid multibyte sequence has been
> encountered in the input";
> +                break;
> +              case EINVAL:
> +                errormessage = "An incomplete multibyte sequence has been
> encountered in the input";
> +                break;
> +              default:
> +                errormessage = "Unknown";
> +                break;
> +            }
> +            msSetError(MS_MISCERR, "Unable to convert string in encoding
> '%s' to UTF8: %s",
> +                                   "msConvertWideStringToUTF8()",
> +                       encoding,errormessage);
> +            iconv_close(cd);
> +            msFree(output);
> +            return NULL;
> +          }
>            iconv_close(cd);
>         } else {
>             msSetError(MS_MISCERR, "Encoding not supported by libiconv
> (%s).",
>                                    "msConvertWideStringToUTF8()",
>                                    encoding);
> +           msFree(output);
>             return NULL;
>         }
> -
> -        if (bconvFailed) {
> -            msFree(output);
> -            output = NULL;
> -            msSetError(MS_MISCERR, "Unable to convert string in encoding
> '%s' to UTF8",
> -                                   "msConvertWideStringToUTF8()",
> -                                   encoding);
> -        }
>     } else {
>         /* we were given a NULL wide string, nothing we can do here */
>         return NULL;
>
> --
>  Russell McOrmond, Internet Consultant: <http://www.flora.ca/>
>  Please help us tell the Canadian Parliament to protect our property
>  rights as owners of Information Technology. Sign the petition!
>  http://digital-copyright.ca/petition/ict/     http://KillBillC61.ca
>
>  "The government, lobbied by legacy copyright holders and hardware
>  manufacturers, can pry control over my camcorder, computer,
>  home theatre, or portable media player from my cold dead hands!"
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>


More information about the mapserver-users mailing list