git: 9bf608d00a4f - releng/13.0 - libc: fix buffer overrun in getrpcport(3)
Edward Tomasz Napierala
trasz at FreeBSD.org
Fri Mar 5 00:36:37 UTC 2021
The branch releng/13.0 has been updated by trasz:
URL: https://cgit.FreeBSD.org/src/commit/?id=9bf608d00a4fa2f2028e555cfd1d7e4f8e56bd38
commit 9bf608d00a4fa2f2028e555cfd1d7e4f8e56bd38
Author: Edward Tomasz Napierala <trasz at FreeBSD.org>
AuthorDate: 2021-01-31 21:41:55 +0000
Commit: Edward Tomasz Napierala <trasz at FreeBSD.org>
CommitDate: 2021-03-04 23:29:00 +0000
libc: fix buffer overrun in getrpcport(3)
Approved by: re (gjb)
Reviewed By: markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27332
(cherry picked from commit 5299d64b2b9f7a25e423ef1785d9402a0ef198d3)
(cherry picked from commit a3576b6207074ba5182be253c26af72f8fb51759)
---
lib/libc/rpc/getrpcport.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/libc/rpc/getrpcport.c b/lib/libc/rpc/getrpcport.c
index 2b2d459c8887..4abc9a0c16af 100644
--- a/lib/libc/rpc/getrpcport.c
+++ b/lib/libc/rpc/getrpcport.c
@@ -62,14 +62,14 @@ getrpcport(char *host, int prognum, int versnum, int proto)
assert(host != NULL);
- if ((hp = gethostbyname(host)) == NULL)
+ if ((hp = gethostbyname2(host, AF_INET)) == NULL)
return (0);
memset(&addr, 0, sizeof(addr));
addr.sin_len = sizeof(struct sockaddr_in);
addr.sin_family = AF_INET;
addr.sin_port = 0;
- if (hp->h_length > addr.sin_len)
- hp->h_length = addr.sin_len;
+ if (hp->h_length > sizeof(addr.sin_addr.s_addr))
+ hp->h_length = sizeof(addr.sin_addr.s_addr);
memcpy(&addr.sin_addr.s_addr, hp->h_addr, (size_t)hp->h_length);
/* Inconsistent interfaces need casts! :-( */
return (pmap_getport(&addr, (u_long)prognum, (u_long)versnum,
More information about the dev-commits-src-all
mailing list