[fpc-pascal] StrToHostAddr in sockets unit accepts negative octets
Karoly Balogh (Charlie/SGR)
charlie at scenergy.dfmk.hu
Sun Apr 19 13:48:24 CEST 2020
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
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 220.127.116.11. 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.
More information about the fpc-pascal