[Shapelib] Memory issue reading string field?

Eduardo Jauch eduardo.jauch at gmail.com
Sat Aug 21 17:57:05 EST 2010


I'm really "out", but if the "size" of the string can cause memory
corruptions, so, maybe, the program have a "limit" to the size of the
string, but is not checking if this limite is been observed...

If the code is in C or C++, probably you are writting after the size of the
variable.

Like if I declare a variable as char name [5]

And then try to put "PESCHEL" in it.

If the program don't check this, you will write over memory that was not
meant to.

Well.

Only an "educated guess" I think...

2010/8/19 Brian Peschel <brianp at occinc.com>

>  I have a simple DBF file I am trying to read:
>
> dBase Reader and Converter V. 0.8, (c) 2002 - 2003 by Bjoern Berg
>
> -- File statistics
> dBase version.........:          FoxBase+/dBASE III+ (without memo)
> Date of last update...:          1995-07-26
> Number of records.....:          1414347 (001594cbd)
> Length of header......:          97 (0061d)
> Record length.........:          81 (0051d)
> Columns in file.......:          2
> Rows in file..........:          1414347
>
> +---------------+-------+---------------+---------------+---------------+
> | field name    | type  | field adress  | length        | field dec.    |
> +---------------+-------+---------------+---------------+---------------+
> |           ID  |   N   |        0      |  10           |   0           |
> |       String  |   C   |        0      |  70           |   0           |
> +---------------+-------+---------------+---------------+---------------+
>
> I am seeing memory corruption in my program after reading this combo from
> the DBF.
>          ID:    1374067
>      String: UNITED STATES DEPARTMENT OF THE INTERIOR PATUXENT WILDLIFE
> RESEARCH CE
> What makes this interesting is the string is 70 characters long (which is
> the width of the field).
>
> If I change the string in the DBF to:
>          ID:    1374067
>      String: US DEPT OF THE INTERIOR PATUXENT WILDLIFE RESEARCH CENTER
> (which is 57 characters) I no longer have any memory corruption.
>
> I tries this on both 1.2.10 and 1.3.0b2.  Any ideas?
>
> - B
>
> _______________________________________________
> Shapelib mailing list
> Shapelib at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/shapelib
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/shapelib/attachments/20100821/1485d59b/attachment.htm 


More information about the Shapelib mailing list