summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2014-07-08 10:12:48 +0000
committerjsing <>2014-07-08 10:12:48 +0000
commita72d3887d3cb2efb2786d7137f32c21895080ba4 (patch)
tree7130d62ad76981509fd8a92db0ccbcb9360644c6
parentc37e27862703a0227027360cdb92a019878e3400 (diff)
downloadopenbsd-a72d3887d3cb2efb2786d7137f32c21895080ba4.tar.gz
openbsd-a72d3887d3cb2efb2786d7137f32c21895080ba4.tar.bz2
openbsd-a72d3887d3cb2efb2786d7137f32c21895080ba4.zip
More KNF.
-rw-r--r--src/lib/libcrypto/bio/b_sock.c32
-rw-r--r--src/lib/libssl/src/crypto/bio/b_sock.c32
2 files changed, 42 insertions, 22 deletions
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index 5a8636f5d7..8fea0b7f8f 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: b_sock.c,v 1.45 2014/07/08 09:46:44 jsing Exp $ */ 1/* $OpenBSD: b_sock.c,v 1.46 2014/07/08 10:12:48 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -95,7 +95,8 @@ BIO_get_host_ip(const char *str, unsigned char *ip)
95 95
96 /* cast to short because of win16 winsock definition */ 96 /* cast to short because of win16 winsock definition */
97 if ((short)he->h_addrtype != AF_INET) { 97 if ((short)he->h_addrtype != AF_INET) {
98 BIOerr(BIO_F_BIO_GET_HOST_IP, BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET); 98 BIOerr(BIO_F_BIO_GET_HOST_IP,
99 BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET);
99 goto err; 100 goto err;
100 } 101 }
101 for (i = 0; i < 4; i++) 102 for (i = 0; i < 4; i++)
@@ -240,8 +241,9 @@ BIO_get_accept_socket(char *host, int bind_mode)
240 break; 241 break;
241 } 242 }
242 } 243 }
244 /* points at last ':', '::port' is special [see below] */
243 if (p) 245 if (p)
244 *p++='\0'; /* points at last ':', '::port' is special [see below] */ 246 *p++ = '\0';
245 else 247 else
246 p = h, h = NULL; 248 p = h, h = NULL;
247 249
@@ -249,10 +251,12 @@ BIO_get_accept_socket(char *host, int bind_mode)
249 do { 251 do {
250 struct addrinfo *res, hint; 252 struct addrinfo *res, hint;
251 253
252 /* '::port' enforces IPv6 wildcard listener. Some OSes, 254 /*
255 * '::port' enforces IPv6 wildcard listener. Some OSes,
253 * e.g. Solaris, default to IPv6 without any hint. Also 256 * e.g. Solaris, default to IPv6 without any hint. Also
254 * note that commonly IPv6 wildchard socket can service 257 * note that commonly IPv6 wildchard socket can service
255 * IPv4 connections just as well... */ 258 * IPv4 connections just as well...
259 */
256 memset(&hint, 0, sizeof(hint)); 260 memset(&hint, 0, sizeof(hint));
257 hint.ai_flags = AI_PASSIVE; 261 hint.ai_flags = AI_PASSIVE;
258 if (h) { 262 if (h) {
@@ -303,7 +307,8 @@ again:
303 if (s == -1) { 307 if (s == -1) {
304 SYSerr(SYS_F_SOCKET, errno); 308 SYSerr(SYS_F_SOCKET, errno);
305 ERR_asprintf_error_data("port='%s'", host); 309 ERR_asprintf_error_data("port='%s'", host);
306 BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_CREATE_SOCKET); 310 BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,
311 BIO_R_UNABLE_TO_CREATE_SOCKET);
307 goto err; 312 goto err;
308 } 313 }
309 314
@@ -311,7 +316,8 @@ again:
311 if (bind_mode == BIO_BIND_REUSEADDR) { 316 if (bind_mode == BIO_BIND_REUSEADDR) {
312 int i = 1; 317 int i = 1;
313 318
314 ret = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&i, sizeof(i)); 319 ret = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&i,
320 sizeof(i));
315 bind_mode = BIO_BIND_NORMAL; 321 bind_mode = BIO_BIND_NORMAL;
316 } 322 }
317#endif 323#endif
@@ -323,10 +329,12 @@ again:
323 client = server; 329 client = server;
324 if (h == NULL || strcmp(h, "*") == 0) { 330 if (h == NULL || strcmp(h, "*") == 0) {
325 if (client.sa.sa_family == AF_INET6) { 331 if (client.sa.sa_family == AF_INET6) {
326 memset(&client.sa_in6.sin6_addr, 0, sizeof(client.sa_in6.sin6_addr)); 332 memset(&client.sa_in6.sin6_addr, 0,
333 sizeof(client.sa_in6.sin6_addr));
327 client.sa_in6.sin6_addr.s6_addr[15] = 1; 334 client.sa_in6.sin6_addr.s6_addr[15] = 1;
328 } else if (client.sa.sa_family == AF_INET) { 335 } else if (client.sa.sa_family == AF_INET) {
329 client.sa_in.sin_addr.s_addr = htonl(0x7F000001); 336 client.sa_in.sin_addr.s_addr =
337 htonl(0x7F000001);
330 } else 338 } else
331 goto err; 339 goto err;
332 } 340 }
@@ -347,13 +355,15 @@ again:
347#endif 355#endif
348 SYSerr(SYS_F_BIND, err_num); 356 SYSerr(SYS_F_BIND, err_num);
349 ERR_asprintf_error_data("port='%s'", host); 357 ERR_asprintf_error_data("port='%s'", host);
350 BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_BIND_SOCKET); 358 BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,
359 BIO_R_UNABLE_TO_BIND_SOCKET);
351 goto err; 360 goto err;
352 } 361 }
353 if (listen(s, SOMAXCONN) == -1) { 362 if (listen(s, SOMAXCONN) == -1) {
354 SYSerr(SYS_F_BIND, errno); 363 SYSerr(SYS_F_BIND, errno);
355 ERR_asprintf_error_data("port='%s'", host); 364 ERR_asprintf_error_data("port='%s'", host);
356 BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_LISTEN_SOCKET); 365 BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,
366 BIO_R_UNABLE_TO_LISTEN_SOCKET);
357 goto err; 367 goto err;
358 } 368 }
359 ret = 1; 369 ret = 1;
diff --git a/src/lib/libssl/src/crypto/bio/b_sock.c b/src/lib/libssl/src/crypto/bio/b_sock.c
index 5a8636f5d7..8fea0b7f8f 100644
--- a/src/lib/libssl/src/crypto/bio/b_sock.c
+++ b/src/lib/libssl/src/crypto/bio/b_sock.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: b_sock.c,v 1.45 2014/07/08 09:46:44 jsing Exp $ */ 1/* $OpenBSD: b_sock.c,v 1.46 2014/07/08 10:12:48 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -95,7 +95,8 @@ BIO_get_host_ip(const char *str, unsigned char *ip)
95 95
96 /* cast to short because of win16 winsock definition */ 96 /* cast to short because of win16 winsock definition */
97 if ((short)he->h_addrtype != AF_INET) { 97 if ((short)he->h_addrtype != AF_INET) {
98 BIOerr(BIO_F_BIO_GET_HOST_IP, BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET); 98 BIOerr(BIO_F_BIO_GET_HOST_IP,
99 BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET);
99 goto err; 100 goto err;
100 } 101 }
101 for (i = 0; i < 4; i++) 102 for (i = 0; i < 4; i++)
@@ -240,8 +241,9 @@ BIO_get_accept_socket(char *host, int bind_mode)
240 break; 241 break;
241 } 242 }
242 } 243 }
244 /* points at last ':', '::port' is special [see below] */
243 if (p) 245 if (p)
244 *p++='\0'; /* points at last ':', '::port' is special [see below] */ 246 *p++ = '\0';
245 else 247 else
246 p = h, h = NULL; 248 p = h, h = NULL;
247 249
@@ -249,10 +251,12 @@ BIO_get_accept_socket(char *host, int bind_mode)
249 do { 251 do {
250 struct addrinfo *res, hint; 252 struct addrinfo *res, hint;
251 253
252 /* '::port' enforces IPv6 wildcard listener. Some OSes, 254 /*
255 * '::port' enforces IPv6 wildcard listener. Some OSes,
253 * e.g. Solaris, default to IPv6 without any hint. Also 256 * e.g. Solaris, default to IPv6 without any hint. Also
254 * note that commonly IPv6 wildchard socket can service 257 * note that commonly IPv6 wildchard socket can service
255 * IPv4 connections just as well... */ 258 * IPv4 connections just as well...
259 */
256 memset(&hint, 0, sizeof(hint)); 260 memset(&hint, 0, sizeof(hint));
257 hint.ai_flags = AI_PASSIVE; 261 hint.ai_flags = AI_PASSIVE;
258 if (h) { 262 if (h) {
@@ -303,7 +307,8 @@ again:
303 if (s == -1) { 307 if (s == -1) {
304 SYSerr(SYS_F_SOCKET, errno); 308 SYSerr(SYS_F_SOCKET, errno);
305 ERR_asprintf_error_data("port='%s'", host); 309 ERR_asprintf_error_data("port='%s'", host);
306 BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_CREATE_SOCKET); 310 BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,
311 BIO_R_UNABLE_TO_CREATE_SOCKET);
307 goto err; 312 goto err;
308 } 313 }
309 314
@@ -311,7 +316,8 @@ again:
311 if (bind_mode == BIO_BIND_REUSEADDR) { 316 if (bind_mode == BIO_BIND_REUSEADDR) {
312 int i = 1; 317 int i = 1;
313 318
314 ret = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&i, sizeof(i)); 319 ret = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&i,
320 sizeof(i));
315 bind_mode = BIO_BIND_NORMAL; 321 bind_mode = BIO_BIND_NORMAL;
316 } 322 }
317#endif 323#endif
@@ -323,10 +329,12 @@ again:
323 client = server; 329 client = server;
324 if (h == NULL || strcmp(h, "*") == 0) { 330 if (h == NULL || strcmp(h, "*") == 0) {
325 if (client.sa.sa_family == AF_INET6) { 331 if (client.sa.sa_family == AF_INET6) {
326 memset(&client.sa_in6.sin6_addr, 0, sizeof(client.sa_in6.sin6_addr)); 332 memset(&client.sa_in6.sin6_addr, 0,
333 sizeof(client.sa_in6.sin6_addr));
327 client.sa_in6.sin6_addr.s6_addr[15] = 1; 334 client.sa_in6.sin6_addr.s6_addr[15] = 1;
328 } else if (client.sa.sa_family == AF_INET) { 335 } else if (client.sa.sa_family == AF_INET) {
329 client.sa_in.sin_addr.s_addr = htonl(0x7F000001); 336 client.sa_in.sin_addr.s_addr =
337 htonl(0x7F000001);
330 } else 338 } else
331 goto err; 339 goto err;
332 } 340 }
@@ -347,13 +355,15 @@ again:
347#endif 355#endif
348 SYSerr(SYS_F_BIND, err_num); 356 SYSerr(SYS_F_BIND, err_num);
349 ERR_asprintf_error_data("port='%s'", host); 357 ERR_asprintf_error_data("port='%s'", host);
350 BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_BIND_SOCKET); 358 BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,
359 BIO_R_UNABLE_TO_BIND_SOCKET);
351 goto err; 360 goto err;
352 } 361 }
353 if (listen(s, SOMAXCONN) == -1) { 362 if (listen(s, SOMAXCONN) == -1) {
354 SYSerr(SYS_F_BIND, errno); 363 SYSerr(SYS_F_BIND, errno);
355 ERR_asprintf_error_data("port='%s'", host); 364 ERR_asprintf_error_data("port='%s'", host);
356 BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_LISTEN_SOCKET); 365 BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,
366 BIO_R_UNABLE_TO_LISTEN_SOCKET);
357 goto err; 367 goto err;
358 } 368 }
359 ret = 1; 369 ret = 1;