[Info-vax] String handling, was: Re: C... the only winning move is not to play...

JF Mezei jfmezei.spamnot at vaxination.ca
Sat Feb 15 15:27:20 EST 2014


On 14-02-15 08:27, VAXman- @SendSpamHere.ORG wrote:

> That's a fixed length string in my view.  Think VMS string descriptor here.
> The storage is allocated to the amount bounded and that memory is made the
> pointer in the descriptor.  The only thing then that changes is the length.

There have been a number of times where I had to load data of unknown
size (think loading a web page in memory to parse it).

When I end up doing is keeping 2 pointers: allocated and used. (integers
containing size, not a pointer)  When "used" reaches "allocated" I would
reallocate the memory to a larger size and update the "allacated" one.

One must go back to the days where those languages were designed to
understand their "primitive" string handling. Back then, data was on 80
character punched cards, with all fields a fixed length. This is why
COBOL for instance has fixed length storage for everything, and why C
string arrays were allocated with fixed sizes.

Back then, you knew in advance how much data you would get.

My guess is that a lot of the buffer overflows in Windows and other
platforms we have seen were due to young programmers not realising the
history of languages that were designed in an area of fixed length
fields and not so well suited to the new internet age where you can't
predict the size of a field/data you will receive.



More information about the Info-vax mailing list