[fpc-pascal] StrToHostAddr in sockets unit accepts negative octets

Noel Duffy noelduffy at xtra.co.nz
Sun Apr 19 23:06:01 CEST 2020

On 19/04/20 11:48 pm, Karoly Balogh (Charlie/SGR) wrote:
> Hi,
> On Sun, 19 Apr 2020, Michael Van Canneyt wrote:
>>> The StrToHostAddr function in the sockets unit accepts negative
>>> octets in the source ip address. Consider this program:
>> This should indeed be ckecked. Please report this in the
>> bugtracker, so we don't forget to look at it!
> I have already fixed it, with a simplistic fix, I think. Committed as
> SVN r44845.
> Basically it was wrapping everything in the longint number range
> silently to a byte. So for example a string saying '172.300.32.14'
> was accepted as IP My patch fixes this too, not just
> the negatives, but please feel free to verify, or improve on it if
> you feel like.
> This was an ancient bug, the code in question was unchanged since SVN
> rev 1, so 2005 at least, but probably longer.

Great, good to know it's fixed. Not having the SVN repo to hand, I can't
tell how recent that revision is. Has this change made it to any
released version of the compiler?

If it hasn't then I will have to either roll a custom function or look
to falling back on the system native libc's inet_pton function.

More information about the fpc-pascal mailing list