summaryrefslogtreecommitdiff
blob: 423c0712f797fab01a052f8acf9fe19d80022fe1 (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
27
28
29
30
31
32
33
34
35
Status of this patch: Reported upstream.

The following assignment in libGeoIP/GeoIP.c is broken on ppc64:
  addr = *((unsigned long *) phe->h_addr_list[0]);

phe->h_addr_list[0] on linux has type in_addr_t which is defined as:
  typedef uint32_t in_addr_t;

On ppc64 sizeof(unsigned long) is 8 (!= 4, sizeof(uint32_t)). This code works
on amd64 as it's little endian, while it became broken on big endian ppc64
systems.


--- libGeoIP/GeoIP.c	2008-12-28 17:36:55 +0000
+++ libGeoIP/GeoIP.c	2008-12-28 17:37:41 +0000
@@ -811,8 +811,7 @@
 			buflength = buflength * 2;
 			buf = realloc(buf,buflength);
 		}
-#endif
-#ifndef HAVE_GETHOSTBYNAME_R
+#else
 		/* Some systems do not support gethostbyname_r, such as Mac OS X */
 		phe = gethostbyname(host);
 #endif
@@ -820,7 +819,7 @@
 			free(buf);
 			return 0;
 		}
-		addr = *((unsigned long *) phe->h_addr_list[0]);
+		addr = *((in_addr_t *) phe->h_addr_list[0]);
 	}
 #ifdef HAVE_GETHOSTBYNAME_R
 	free(buf);