1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-07-13 23:13:24 +00:00

Check which getprotobynumber_r() variant to use

This commit is contained in:
Gerhard Rieger 2021-11-21 11:15:08 +01:00
parent 33a5019b18
commit ffa09eac00
3 changed files with 27 additions and 4 deletions

View file

@ -253,14 +253,14 @@ int sockname(int fd, FILE *outfile, char style) {
#endif
#if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE)
#if HAVE_GETPROTOBYNUMBER_R
#if HAVE_GETPROTOBYNUMBER_R==1 /* Linux */
rc = getprotobynumber_r(proto, &protoent, protoname, sizeof(protoname), &protoentp);
if (protoentp == NULL) {
Warn2("sockname(): getprotobynumber_r(proto=%d, ...): %s",
proto, strerror(rc));
}
strncpy(protoname, protoentp->p_name, sizeof(protoname));
#elif HAVE_GETPROTOBYNUMBER
#elif HAVE_GETPROTOBYNUMBER_R==2 /* Solaris */
protoentp = getprotobynumber(proto);
strncpy(protoname, protoentp->p_name, sizeof(protoname));
#else