[fpc-pascal] fprecvfrom for IPv6?

Michael Van Canneyt michael at freepascal.org
Sun Aug 2 17:00:08 CEST 2015



On Sun, 2 Aug 2015, Klaus Hartnegg wrote:

> Hello,
>
> How can fprecvfrom work with IPv6?
>
> It returns the address of the sender in a record sockaddr, which only has 
> space for an IPv4 address.
> http://www.freepascal.org/docs-html/rtl/sockets/fprecvfrom.html
>
> Is there an undocumented variant in which psockaddr points to sockaddr_in6 
> instead of sockaddr?

No.

> Or is this already the case in the existing fprecvfrom?

The call itself does not do any checking on the length.
You will have to typecast your pointer till we add an overloaded version for IPV6.

> One of my programs suddenly claims that fprecvfrom returned an address record 
> with size 28 bytes instead of 16 (in fromlen:pSockLen), when it runs in 
> Redhat (using xinetd) instead of Ubuntu (using openbsd-inetd), when receiving 
> an UDP packet. Interestingly sizeof(sockaddr_in6) is 28. Probably not a 
> coincidence, but I whish it were documented, because I don't want to develop 
> software based on guessing.

Neither do we.

> Btw. what does fpcrectfrom do when fromlen^ is smaller than the amount of 
> data that it wants to copy to psockaddr^? Buffer overflow?

It does not do anything. The call will work regardless of the size of the IP address.
These parameters are pointers, no checking on length is done by FPC code.

It just means we'll have to make an overloaded version.
Please enter a bugreport in the bugtracker, so it is not forgotten.

Michael.



More information about the fpc-pascal mailing list