summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/libtirpc/libtirpc-0.2.2/libtirpc-0.2.1-fortify.patch
blob: 4a785d344a436c5dc2a49ab07be45daafedc7380 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Fix a possible overflow (reported by _FORTIFY_SOURCE=2)

Ported from Gentoo

Upstream-Status: Pending

Signed-off-by: Khem Raj <raj.khem@gmail.com>

Index: libtirpc-0.2.1/src/getrpcport.c
===================================================================
--- libtirpc-0.2.1.orig/src/getrpcport.c
+++ libtirpc-0.2.1/src/getrpcport.c
@@ -54,11 +54,11 @@ getrpcport(host, prognum, versnum, proto
 
 	if ((hp = gethostbyname(host)) == NULL)
 		return (0);
+	if (hp->h_length != sizeof(addr.sin_addr.s_addr))
+		return (0);
 	memset(&addr, 0, sizeof(addr));
 	addr.sin_family = AF_INET;
 	addr.sin_port =  0;
-	if (hp->h_length > sizeof(addr))
-	  hp->h_length = sizeof(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,