updated on Tue Jan 10 04:01:21 UTC 2012
[aur-mirror.git] / lprng / gcc-4.4fix.diff
blobf41aec4ec2543f1bccb0961e406261f671b07922
1 --- src/common/lpd_dispatch.c~ 2005-04-14 22:05:18.000000000 +0200
2 +++ src/common/lpd_dispatch.c 2009-05-09 00:28:56.588433281 +0200
3 @@ -157,9 +157,16 @@
4 int status; /* status of operation */
5 int permission;
6 int port = 0;
7 - struct sockaddr sinaddr;
8 + union {
9 + struct sockaddr_storage sa_stor;
10 + struct sockaddr sinaddr;
11 + struct sockaddr_in sa_in;
12 +#ifdef AF_INET6
13 + struct sockaddr_in6 sa_in6;
14 +#endif
15 + } s;
17 - memset( &sinaddr, 0, sizeof(sinaddr) );
18 + memset( &s, 0, sizeof(s) );
19 Name = "SERVER";
20 setproctitle( "lpd %s", Name );
21 (void) plp_signal (SIGHUP, cleanup );
22 @@ -182,8 +189,8 @@
23 #else
24 int len;
25 #endif
26 - len = sizeof( sinaddr );
27 - if( getpeername( talk, &sinaddr, &len ) ){
28 + len = sizeof( s.sinaddr );
29 + if( getpeername( talk, &s.sinaddr, &len ) ){
30 LOGERR_DIE(LOG_DEBUG) _("Service_connection: getpeername failed") );
33 @@ -195,7 +202,7 @@
34 #ifdef AF_UNIX
35 "AF_UNIX %d"
36 #endif
37 - "%s" , sinaddr.sa_family,
38 + "%s" , s.sinaddr.sa_family,
39 #ifdef AF_LOCAL
40 AF_LOCAL,
41 #endif
42 @@ -203,43 +210,43 @@
43 AF_UNIX,
44 #endif
45 "");
46 - if( sinaddr.sa_family == AF_INET ){
47 - port = ((struct sockaddr_in *)&sinaddr)->sin_port;
48 + if( s.sinaddr.sa_family == AF_INET ){
49 + port = s.sa_in.sin_port;
50 #if defined(IPV6)
51 - } else if( sinaddr.sa_family == AF_INET6 ){
52 - port = ((struct sockaddr_in6 * )&sinaddr)->sin6_port;
53 + } else if( s.sinaddr.sa_family == AF_INET6 ){
54 + port = s.sa_in6.sin6_port;
55 #endif
56 - } else if( sinaddr.sa_family == 0
57 + } else if( s.sinaddr.sa_family == 0
58 #if defined(AF_LOCAL)
59 - || sinaddr.sa_family == AF_LOCAL
60 + || s.sinaddr.sa_family == AF_LOCAL
61 #endif
62 #if defined(AF_UNIX)
63 - || sinaddr.sa_family == AF_UNIX
64 + || s.sinaddr.sa_family == AF_UNIX
65 #endif
67 /* force the localhost address */
68 int len;
69 - void *s, *addr;
70 - memset( &sinaddr, 0, sizeof(sinaddr) );
71 + void *s1, *addr;
72 + memset( &s, 0, sizeof(s) );
73 Perm_check.unix_socket = 1;
74 - sinaddr.sa_family = Localhost_IP.h_addrtype;
75 + s.sinaddr.sa_family = Localhost_IP.h_addrtype;
76 len = Localhost_IP.h_length;
77 - if( sinaddr.sa_family == AF_INET ){
78 - addr = &(((struct sockaddr_in *)&sinaddr)->sin_addr);
79 + if( s.sinaddr.sa_family == AF_INET ){
80 + addr = (void *) &s.sa_in.sin_addr;
81 #if defined(IPV6)
82 - } else if( sinaddr.sa_family == AF_INET6 ){
83 - addr = &(((struct sockaddr_in6 *)&sinaddr)->sin6_addr);
84 + } else if( s.sinaddr.sa_family == AF_INET6 ){
85 + addr = (void *) &s.sa_in6.sin6_addr;
86 #endif
87 } else {
88 FATAL(LOG_INFO) _("Service_connection: BAD LocalHost_IP value"));
89 addr = 0;
91 - s = Localhost_IP.h_addr_list.list[0];
92 - memmove(addr,s,len);
93 + s1 = Localhost_IP.h_addr_list.list[0];
94 + memmove(addr,s1,len);
95 } else {
96 - FATAL(LOG_INFO) _("Service_connection: bad protocol family '%d'"), sinaddr.sa_family );
97 + FATAL(LOG_INFO) _("Service_connection: bad protocol family '%d'"), s.sinaddr.sa_family );
99 - inet_ntop_sockaddr( &sinaddr, from_addr, sizeof(from_addr) );
100 + inet_ntop_sockaddr( &s.sinaddr, from_addr, sizeof(from_addr) );
102 int len = strlen(from_addr);
103 SNPRINTF(from_addr+len,sizeof(from_addr)-len)" port %d", ntohs(port));
104 @@ -249,7 +256,7 @@
106 /* get the remote name and set up the various checks */
108 - Get_remote_hostbyaddr( &RemoteHost_IP, &sinaddr, 0 );
109 + Get_remote_hostbyaddr( &RemoteHost_IP, &s.sinaddr, 0 );
110 Perm_check.remotehost = &RemoteHost_IP;
111 Perm_check.host = &RemoteHost_IP;
112 Perm_check.port = ntohs(port);