summaryrefslogtreecommitdiff
path: root/src/network/getservbyport_r.c
AgeCommit message (Collapse)AuthorLines
2023-02-28getservbyport_r: fix wrong result if getnameinfo fails with EAI_OVERFLOWAlexey Izbyshev-0/+2
EAI_OVERFLOW should be propagated as ERANGE to inform the caller about the need to expand the buffer.
2023-02-28getservbyport_r: fix out-of-bounds buffer readAlexey Izbyshev-1/+1
If the buffer passed to getservbyport_r is just enough to store two pointers after aligning it, getnameinfo is called with buflen == 0 (which means that service name is not needed) and trivially succeeds. Then, strtol is called on the address just past the buffer end, and if it doesn't happen to find the port number there, getservbyport_r spuriously succeeds and returns the same bad address to the caller. Fix this by ensuring that buflen is at least 1 when passed to getnameinfo.
2017-09-06don't treat numeric port strings as servent records in getservby*()Rich Felker-0/+4
some applications use getservbyport to find port numbers that are not assigned to a service; if getservbyport always succeeds with a numeric string as the result, they fail to find any available ports. POSIX doesn't seem to mandate the behavior one way or another. it specifies an abstract service database, which an implementation could define to include numeric port strings, but it makes more sense to align behavior with traditional implementations. based on patch by A. Wilcox. the original patch only changed getservbyport[_r]. to maintain a consistent view of the "service database", I have also modified getservbyname[_r] to exclude numeric port strings.
2016-09-24fix getservby*_r result pointer value on errorDaniel Sabogal-0/+1
this is a clone of the fix to the gethostby*_r functions in commit fe82bb9b921be34370e6b71a1c6f062c20999ae0. the man pages document that the getservby*_r functions set this pointer to NULL if there was an error or if no record was found.
2012-07-22make getservby*_r return error code rather than -1 (and using errno)Rich Felker-10/+18
untested but should be correct..
2012-07-14fix getservby*() with null pointer for protocol argumentRich Felker-0/+4
not sure this is the best fix but it should work
2011-09-13remove some stray trailing space charactersRich Felker-1/+1
2011-02-12initial check-in, version 0.5.0v0.5.0Rich Felker-0/+43