/[smeserver]/rpms/openssl/sme8/openssl-0.9.8b-ipv6-apps.patch
ViewVC logotype

Contents of /rpms/openssl/sme8/openssl-0.9.8b-ipv6-apps.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Tue Feb 18 03:03:08 2014 UTC (10 years, 8 months ago) by wellsi
Branch: MAIN
CVS Tags: openssl-0_9_8e-28_el5_sme, openssl-0_9_8e-33_1_el5_sme, openssl-0_9_8e-32_1_el5_sme, openssl-0_9_8e-27_1_el5_sme, openssl-0_9_8e-27_el5_10_1, openssl-0_9_8e-31_1_el5_sme, HEAD
Branch point for: upstream
Initial import

1 diff --exclude-from=exclude-diff-openssl-0.9.8b -bru openssl-0.9.8b.orig/apps/s_apps.h openssl-0.9.8b/apps/s_apps.h
2 --- openssl-0.9.8b.orig/apps/s_apps.h 2006-07-11 16:14:29.000000000 +0200
3 +++ openssl-0.9.8b/apps/s_apps.h 2006-07-13 08:44:29.000000000 +0200
4 @@ -148,7 +148,7 @@
5 #define PORT_STR "4433"
6 #define PROTOCOL "tcp"
7
8 -int do_server(int port, int type, int *ret, int (*cb) (char *hostname, int s, unsigned char *context), unsigned char *context);
9 +int do_server(char *port, int type, int *ret, int (*cb) (char *hostname, int s, unsigned char *context), unsigned char *context);
10 #ifdef HEADER_X509_H
11 int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
12 #endif
13 @@ -156,10 +156,9 @@
14 int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file);
15 int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key);
16 #endif
17 -int init_client(int *sock, char *server, int port, int type);
18 +int init_client(int *sock, char *server, char *port, int type);
19 int should_retry(int i);
20 -int extract_port(char *str, short *port_ptr);
21 -int extract_host_port(char *str,char **host_ptr,unsigned char *ip,short *p);
22 +int extract_host_port(char *str,char **host_ptr,char **port_ptr);
23
24 long MS_CALLBACK bio_dump_callback(BIO *bio, int cmd, const char *argp,
25 int argi, long argl, long ret);
26 diff --exclude-from=exclude-diff-openssl-0.9.8b -bru openssl-0.9.8b.orig/apps/s_client.c openssl-0.9.8b/apps/s_client.c
27 --- openssl-0.9.8b.orig/apps/s_client.c 2005-11-25 14:46:41.000000000 +0100
28 +++ openssl-0.9.8b/apps/s_client.c 2006-07-13 08:44:29.000000000 +0200
29 @@ -246,7 +246,7 @@
30 int cbuf_len,cbuf_off;
31 int sbuf_len,sbuf_off;
32 fd_set readfds,writefds;
33 - short port=PORT;
34 + char *port_str = PORT_STR;
35 int full_log=1;
36 char *host=SSL_HOST_NAME;
37 char *cert_file=NULL,*key_file=NULL;
38 @@ -330,13 +330,12 @@
39 else if (strcmp(*argv,"-port") == 0)
40 {
41 if (--argc < 1) goto bad;
42 - port=atoi(*(++argv));
43 - if (port == 0) goto bad;
44 + port_str= *(++argv);
45 }
46 else if (strcmp(*argv,"-connect") == 0)
47 {
48 if (--argc < 1) goto bad;
49 - if (!extract_host_port(*(++argv),&host,NULL,&port))
50 + if (!extract_host_port(*(++argv),&host,&port_str))
51 goto bad;
52 }
53 else if (strcmp(*argv,"-verify") == 0)
54 @@ -619,7 +618,7 @@
55
56 re_start:
57
58 - if (init_client(&s,host,port,sock_type) == 0)
59 + if (init_client(&s,host,port_str,sock_type) == 0)
60 {
61 BIO_printf(bio_err,"connect:errno=%d\n",get_last_socket_error());
62 SHUTDOWN(s);
63 diff --exclude-from=exclude-diff-openssl-0.9.8b -bru openssl-0.9.8b.orig/apps/s_server.c openssl-0.9.8b/apps/s_server.c
64 --- openssl-0.9.8b.orig/apps/s_server.c 2005-09-02 14:27:02.000000000 +0200
65 +++ openssl-0.9.8b/apps/s_server.c 2006-07-13 08:44:29.000000000 +0200
66 @@ -532,7 +532,7 @@
67 {
68 X509_STORE *store = NULL;
69 int vflags = 0;
70 - short port=PORT;
71 + char *port_str = PORT_STR;
72 char *CApath=NULL,*CAfile=NULL;
73 unsigned char *context = NULL;
74 char *dhfile = NULL;
75 @@ -597,8 +597,7 @@
76 (strcmp(*argv,"-accept") == 0))
77 {
78 if (--argc < 1) goto bad;
79 - if (!extract_port(*(++argv),&port))
80 - goto bad;
81 + port_str= *(++argv);
82 }
83 else if (strcmp(*argv,"-verify") == 0)
84 {
85 @@ -1086,9 +1085,9 @@
86
87 BIO_printf(bio_s_out,"ACCEPT\n");
88 if (www)
89 - do_server(port,sock_type,&accept_socket,www_body, context);
90 + do_server(port_str,sock_type,&accept_socket,www_body, context);
91 else
92 - do_server(port,sock_type,&accept_socket,sv_body, context);
93 + do_server(port_str,sock_type,&accept_socket,sv_body, context);
94 print_stats(bio_s_out,ctx);
95 ret=0;
96 end:
97 diff --exclude-from=exclude-diff-openssl-0.9.8b -bru openssl-0.9.8b.orig/apps/s_socket.c openssl-0.9.8b/apps/s_socket.c
98 --- openssl-0.9.8b.orig/apps/s_socket.c 2005-06-13 05:21:00.000000000 +0200
99 +++ openssl-0.9.8b/apps/s_socket.c 2006-07-13 08:44:29.000000000 +0200
100 @@ -96,9 +96,7 @@
101 static void ssl_sock_cleanup(void);
102 #endif
103 static int ssl_sock_init(void);
104 -static int init_client_ip(int *sock,unsigned char ip[4], int port, int type);
105 -static int init_server(int *sock, int port, int type);
106 -static int init_server_long(int *sock, int port,char *ip, int type);
107 +static int init_server(int *sock, char *port, int type);
108 static int do_accept(int acc_sock, int *sock, char **host);
109 static int host_ip(char *str, unsigned char ip[4]);
110
111 @@ -228,60 +226,69 @@
112 return(1);
113 }
114
115 -int init_client(int *sock, char *host, int port, int type)
116 +int init_client(int *sock, char *host, char *port, int type)
117 {
118 - unsigned char ip[4];
119 - short p=0;
120 -
121 - if (!host_ip(host,&(ip[0])))
122 - {
123 - return(0);
124 - }
125 - if (p != 0) port=p;
126 - return(init_client_ip(sock,ip,port,type));
127 - }
128 -
129 -static int init_client_ip(int *sock, unsigned char ip[4], int port, int type)
130 - {
131 - unsigned long addr;
132 - struct sockaddr_in them;
133 - int s,i;
134 + struct addrinfo *res, *res0, hints;
135 + char * failed_call = NULL;
136 + int s;
137 + int e;
138
139 if (!ssl_sock_init()) return(0);
140
141 - memset((char *)&them,0,sizeof(them));
142 - them.sin_family=AF_INET;
143 - them.sin_port=htons((unsigned short)port);
144 - addr=(unsigned long)
145 - ((unsigned long)ip[0]<<24L)|
146 - ((unsigned long)ip[1]<<16L)|
147 - ((unsigned long)ip[2]<< 8L)|
148 - ((unsigned long)ip[3]);
149 - them.sin_addr.s_addr=htonl(addr);
150 -
151 - if (type == SOCK_STREAM)
152 - s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL);
153 - else /* ( type == SOCK_DGRAM) */
154 - s=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
155 -
156 - if (s == INVALID_SOCKET) { perror("socket"); return(0); }
157 + memset(&hints, '\0', sizeof(hints));
158 + hints.ai_socktype = type;
159 + hints.ai_flags = AI_ADDRCONFIG;
160 +
161 + e = getaddrinfo(host, port, &hints, &res);
162 + if (e)
163 + {
164 + fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(e));
165 + if (e == EAI_SYSTEM)
166 + perror("getaddrinfo");
167 + return (0);
168 + }
169
170 + res0 = res;
171 + while (res)
172 + {
173 + s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
174 + if (s == INVALID_SOCKET)
175 + {
176 + failed_call = "socket";
177 + goto nextres;
178 + }
179 #ifndef OPENSSL_SYS_MPE
180 if (type == SOCK_STREAM)
181 {
182 - i=0;
183 - i=setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
184 - if (i < 0) { perror("keepalive"); return(0); }
185 + int i=0;
186 + i=setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,
187 + (char *)&i,sizeof(i));
188 + if (i < 0) {
189 + failed_call = "keepalive";
190 + goto nextres;
191 + }
192 }
193 #endif
194 -
195 - if (connect(s,(struct sockaddr *)&them,sizeof(them)) == -1)
196 - { close(s); perror("connect"); return(0); }
197 + if (connect(s,(struct sockaddr *)res->ai_addr,
198 + res->ai_addrlen) == 0)
199 + {
200 + freeaddrinfo(res0);
201 *sock=s;
202 return(1);
203 }
204 + failed_call = "socket";
205 +nextres:
206 + if (s != INVALID_SOCKET)
207 + close(s);
208 + res = res->ai_next;
209 + }
210 + freeaddrinfo(res0);
211 +
212 + perror(failed_call);
213 + return(0);
214 + }
215
216 -int do_server(int port, int type, int *ret, int (*cb)(char *hostname, int s, unsigned char *context), unsigned char *context)
217 +int do_server(char *port, int type, int *ret, int (*cb)(char *hostname, int s, unsigned char *context), unsigned char *context)
218 {
219 int sock;
220 char *name = NULL;
221 @@ -319,33 +326,38 @@
222 }
223 }
224
225 -static int init_server_long(int *sock, int port, char *ip, int type)
226 +static int init_server(int *sock, char *port, int type)
227 {
228 - int ret=0;
229 - struct sockaddr_in server;
230 - int s= -1,i;
231 + struct addrinfo *res, *res0, hints;
232 + char * failed_call = NULL;
233 + char port_name[8];
234 + int s;
235 + int e;
236
237 if (!ssl_sock_init()) return(0);
238
239 - memset((char *)&server,0,sizeof(server));
240 - server.sin_family=AF_INET;
241 - server.sin_port=htons((unsigned short)port);
242 - if (ip == NULL)
243 - server.sin_addr.s_addr=INADDR_ANY;
244 - else
245 -/* Added for T3E, address-of fails on bit field (beckman@acl.lanl.gov) */
246 -#ifndef BIT_FIELD_LIMITS
247 - memcpy(&server.sin_addr.s_addr,ip,4);
248 -#else
249 - memcpy(&server.sin_addr,ip,4);
250 -#endif
251 -
252 - if (type == SOCK_STREAM)
253 - s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL);
254 - else /* type == SOCK_DGRAM */
255 - s=socket(AF_INET, SOCK_DGRAM,IPPROTO_UDP);
256 + memset(&hints, '\0', sizeof(hints));
257 + hints.ai_socktype = type;
258 + hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
259 +
260 + e = getaddrinfo(NULL, port, &hints, &res);
261 + if (e)
262 + {
263 + fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(e));
264 + if (e == EAI_SYSTEM)
265 + perror("getaddrinfo");
266 + return (0);
267 + }
268
269 - if (s == INVALID_SOCKET) goto err;
270 + res0 = res;
271 + while (res)
272 + {
273 + s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
274 + if (s == INVALID_SOCKET)
275 + {
276 + failed_call = "socket";
277 + goto nextres;
278 + }
279 #if defined SOL_SOCKET && defined SO_REUSEADDR
280 {
281 int j = 1;
282 @@ -353,36 +365,39 @@
283 (void *) &j, sizeof j);
284 }
285 #endif
286 - if (bind(s,(struct sockaddr *)&server,sizeof(server)) == -1)
287 +
288 + if (bind(s,(struct sockaddr *)res->ai_addr, res->ai_addrlen) == -1)
289 {
290 -#ifndef OPENSSL_SYS_WINDOWS
291 - perror("bind");
292 -#endif
293 - goto err;
294 + failed_call = "bind";
295 + goto nextres;
296 }
297 - /* Make it 128 for linux */
298 - if (type==SOCK_STREAM && listen(s,128) == -1) goto err;
299 - i=0;
300 - *sock=s;
301 - ret=1;
302 -err:
303 - if ((ret == 0) && (s != -1))
304 + if (type==SOCK_STREAM && listen(s,128) == -1)
305 {
306 - SHUTDOWN(s);
307 + failed_call = "listen";
308 + goto nextres;
309 }
310 - return(ret);
311 +
312 + *sock=s;
313 + return(1);
314 +
315 +nextres:
316 + if (s != INVALID_SOCKET)
317 + close(s);
318 + res = res->ai_next;
319 }
320 + freeaddrinfo(res0);
321
322 -static int init_server(int *sock, int port, int type)
323 - {
324 - return(init_server_long(sock, port, NULL, type));
325 + if (s == INVALID_SOCKET) { perror("socket"); return(0); }
326 +
327 + perror(failed_call);
328 + return(0);
329 }
330
331 static int do_accept(int acc_sock, int *sock, char **host)
332 {
333 - int ret,i;
334 - struct hostent *h1,*h2;
335 - static struct sockaddr_in from;
336 + static struct sockaddr_storage from;
337 + char buffer[NI_MAXHOST];
338 + int ret;
339 int len;
340 /* struct linger ling; */
341
342 @@ -427,137 +442,62 @@
343 if (i < 0) { perror("keepalive"); return(0); }
344 */
345
346 - if (host == NULL) goto end;
347 -#ifndef BIT_FIELD_LIMITS
348 - /* I should use WSAAsyncGetHostByName() under windows */
349 - h1=gethostbyaddr((char *)&from.sin_addr.s_addr,
350 - sizeof(from.sin_addr.s_addr),AF_INET);
351 -#else
352 - h1=gethostbyaddr((char *)&from.sin_addr,
353 - sizeof(struct in_addr),AF_INET);
354 -#endif
355 - if (h1 == NULL)
356 + if (host == NULL)
357 {
358 - BIO_printf(bio_err,"bad gethostbyaddr\n");
359 - *host=NULL;
360 - /* return(0); */
361 - }
362 - else
363 - {
364 - if ((*host=(char *)OPENSSL_malloc(strlen(h1->h_name)+1)) == NULL)
365 - {
366 - perror("OPENSSL_malloc");
367 - return(0);
368 + *sock=ret;
369 + return(1);
370 }
371 - BUF_strlcpy(*host,h1->h_name,strlen(h1->h_name)+1);
372
373 - h2=GetHostByName(*host);
374 - if (h2 == NULL)
375 + if (getnameinfo((struct sockaddr *)&from, sizeof(from),
376 + buffer, sizeof(buffer),
377 + NULL, 0, 0))
378 {
379 - BIO_printf(bio_err,"gethostbyname failure\n");
380 + BIO_printf(bio_err,"getnameinfo failed\n");
381 + *host=NULL; *sock=ret;
382 + return(1);
383 - return(0);
384 }
385 - i=0;
386 - if (h2->h_addrtype != AF_INET)
387 + else
388 {
389 - BIO_printf(bio_err,"gethostbyname addr is not AF_INET\n");
390 + if ((*host=(char *)OPENSSL_malloc(strlen(buffer)+1)) == NULL)
391 + {
392 + perror("OPENSSL_malloc");
393 return(0);
394 }
395 - }
396 -end:
397 + strcpy(*host, buffer);
398 *sock=ret;
399 return(1);
400 }
401 + }
402
403 -int extract_host_port(char *str, char **host_ptr, unsigned char *ip,
404 - short *port_ptr)
405 +int extract_host_port(char *str, char **host_ptr,
406 + char **port_ptr)
407 {
408 - char *h,*p;
409 + char *h,*p,*x;
410
411 - h=str;
412 - p=strchr(str,':');
413 + x=h=str;
414 + if (*h == '[')
415 + {
416 + h++;
417 + p=strchr(h,']');
418 if (p == NULL)
419 {
420 - BIO_printf(bio_err,"no port defined\n");
421 + BIO_printf(bio_err,"no ending bracket for IPv6 address\n");
422 return(0);
423 }
424 *(p++)='\0';
425 -
426 - if ((ip != NULL) && !host_ip(str,ip))
427 - goto err;
428 - if (host_ptr != NULL) *host_ptr=h;
429 -
430 - if (!extract_port(p,port_ptr))
431 - goto err;
432 - return(1);
433 -err:
434 - return(0);
435 + x = p;
436 }
437 -
438 -static int host_ip(char *str, unsigned char ip[4])
439 - {
440 - unsigned int in[4];
441 - int i;
442 -
443 - if (sscanf(str,"%u.%u.%u.%u",&(in[0]),&(in[1]),&(in[2]),&(in[3])) == 4)
444 - {
445 - for (i=0; i<4; i++)
446 - if (in[i] > 255)
447 - {
448 - BIO_printf(bio_err,"invalid IP address\n");
449 - goto err;
450 - }
451 - ip[0]=in[0];
452 - ip[1]=in[1];
453 - ip[2]=in[2];
454 - ip[3]=in[3];
455 - }
456 - else
457 - { /* do a gethostbyname */
458 - struct hostent *he;
459 -
460 - if (!ssl_sock_init()) return(0);
461 -
462 - he=GetHostByName(str);
463 - if (he == NULL)
464 - {
465 - BIO_printf(bio_err,"gethostbyname failure\n");
466 - goto err;
467 - }
468 - /* cast to short because of win16 winsock definition */
469 - if ((short)he->h_addrtype != AF_INET)
470 + p=strchr(x,':');
471 + if (p == NULL)
472 {
473 - BIO_printf(bio_err,"gethostbyname addr is not AF_INET\n");
474 - return(0);
475 - }
476 - ip[0]=he->h_addr_list[0][0];
477 - ip[1]=he->h_addr_list[0][1];
478 - ip[2]=he->h_addr_list[0][2];
479 - ip[3]=he->h_addr_list[0][3];
480 - }
481 - return(1);
482 -err:
483 + BIO_printf(bio_err,"no port defined\n");
484 return(0);
485 }
486 + *(p++)='\0';
487
488 -int extract_port(char *str, short *port_ptr)
489 - {
490 - int i;
491 - struct servent *s;
492 + if (host_ptr != NULL) *host_ptr=h;
493 + if (port_ptr != NULL) *port_ptr=p;
494
495 - i=atoi(str);
496 - if (i != 0)
497 - *port_ptr=(unsigned short)i;
498 - else
499 - {
500 - s=getservbyname(str,"tcp");
501 - if (s == NULL)
502 - {
503 - BIO_printf(bio_err,"getservbyname failure for %s\n",str);
504 - return(0);
505 - }
506 - *port_ptr=ntohs((unsigned short)s->s_port);
507 - }
508 return(1);
509 }
510

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed