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
4 int status; /* status of operation */
7 - struct sockaddr sinaddr;
9 + struct sockaddr_storage sa_stor;
10 + struct sockaddr sinaddr;
11 + struct sockaddr_in sa_in;
13 + struct sockaddr_in6 sa_in6;
17 - memset( &sinaddr, 0, sizeof(sinaddr) );
18 + memset( &s, 0, sizeof(s) );
20 setproctitle( "lpd %s", Name );
21 (void) plp_signal (SIGHUP, cleanup );
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") );
37 - "%s" , sinaddr.sa_family,
38 + "%s" , s.sinaddr.sa_family,
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;
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;
56 - } else if( sinaddr.sa_family == 0
57 + } else if( s.sinaddr.sa_family == 0
59 - || sinaddr.sa_family == AF_LOCAL
60 + || s.sinaddr.sa_family == AF_LOCAL
63 - || sinaddr.sa_family == AF_UNIX
64 + || s.sinaddr.sa_family == AF_UNIX
67 /* force the localhost address */
70 - memset( &sinaddr, 0, sizeof(sinaddr) );
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;
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;
88 FATAL(LOG_INFO) _("Service_connection: BAD LocalHost_IP value"));
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);
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));
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);