Magnus Hagander <magnus@hagander.net> writes:
> Given this, perhaps the proper approach should instead be to just check
> the return value, and go from there? Should be a simple enough patch,
> something like the attached.
> Tom, can you comment?
Testing against INT_MAX seems like a type pun, or something. Maybe use
MaxAllocSize instead?
if (xfrmlen >= MaxAllocSize)
return val;
Also, since as you note returning (size_t) -1 is not at all standard,
it would be helpful to readers to note that that's what Windows does
on failure and that's what you're testing for. In fact you could
make a good case that the test should be just
if (xfrmlen == (size_t) -1)
return val;
regards, tom lane