getservbyport_r: fix wrong result if getnameinfo fails with EAI_OVERFLOW
authorAlexey Izbyshev <izbyshev@ispras.ru>
Mon, 27 Feb 2023 20:33:08 +0000 (23:33 +0300)
committerRich Felker <dalias@aerifal.cx>
Tue, 28 Feb 2023 17:01:34 +0000 (12:01 -0500)
EAI_OVERFLOW should be propagated as ERANGE to inform the caller about
the need to expand the buffer.

src/network/getservbyport_r.c

index d3a22b8..e4cc307 100644 (file)
@@ -46,6 +46,8 @@ int getservbyport_r(int port, const char *prots,
        case EAI_MEMORY:
        case EAI_SYSTEM:
                return ENOMEM;
+       case EAI_OVERFLOW:
+               return ERANGE;
        default:
                return ENOENT;
        case 0: