OSDN Git Service

don't treat numeric port strings as servent records in getservby*()
authorRich Felker <dalias@aerifal.cx>
Thu, 7 Sep 2017 01:42:15 +0000 (21:42 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 7 Sep 2017 01:42:15 +0000 (21:42 -0400)
commit565dbee24d4bf55728be1c274fca1e7f3196fd73
tree157ebbac897879151a8c14780e682f58b241fb6d
parent9e01be6e49b9ae433072207f420ef33c8189eb78
don't treat numeric port strings as servent records in getservby*()

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.
src/network/getservbyname_r.c
src/network/getservbyport_r.c