[GRASS-dev] Right way to use G_getl2

Hamish hamish_b at yahoo.com
Fri Sep 13 16:50:13 PDT 2013

Markus Metz wrote:

> I would suggest to modify G_getl2() to read at most n (not n - 1)
> characters and include a check if the buffer is long enough:

mmmph, to me G_get2() does the right thing, as long as people follow
the given instructions all is fine. So I'd vote to keep it as-is.

FWIW, "at most one less than size characters from stream" follows
the behaviour of fgets() and (programmer)fails on the side of not
overflowing the given output buffer.

The \n and \r chars are not stored in the output string, and are not
left in the input stream for the next line. (if this wasn't the case
it's pretty hard to imagine that we wouldn't have noticed corrupted
ascii file input over the last 4 years)

is there a ticket for the 'v.in.ascii skip=' overflow problem? if not
can someone open one with a problematic input file attached? I suspect
the recent patch is perhaps fixing a problem actually rooted somewhere


More information about the grass-dev mailing list