Skip to content

Commit 8d7a3f4

Browse files
Daniel Sabogalrichfelker
authored andcommitted
fix getservby*_r result pointer value on error
this is a clone of the fix to the gethostby*_r functions in commit fe82bb9. 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.
1 parent d917ef0 commit 8d7a3f4

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/network/getservbyname_r.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ int getservbyname_r(const char *name, const char *prots,
1515
struct service servs[MAXSERVS];
1616
int cnt, proto, align;
1717

18+
*res = 0;
19+
1820
/* Align buffer */
1921
align = -(uintptr_t)buf & ALIGN-1;
2022
if (buflen < 2*sizeof(char *)+align)

src/network/getservbyport_r.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ int getservbyport_r(int port, const char *prots,
2020
if (r) r = getservbyport_r(port, "udp", se, buf, buflen, res);
2121
return r;
2222
}
23+
*res = 0;
2324

2425
/* Align buffer */
2526
i = (uintptr_t)buf & sizeof(char *)-1;

0 commit comments

Comments
 (0)