diff options
author | deraadt <> | 2015-09-11 21:22:54 +0000 |
---|---|---|
committer | deraadt <> | 2015-09-11 21:22:54 +0000 |
commit | fd7ba321fde0d383e365368c92e2b4fd7d3545a1 (patch) | |
tree | e5b771cccef4d397760253e47ca507aee2c9732f | |
parent | 37a2330d0f355087b739ffe7d0a69f1f0d87055d (diff) | |
download | openbsd-fd7ba321fde0d383e365368c92e2b4fd7d3545a1.tar.gz openbsd-fd7ba321fde0d383e365368c92e2b4fd7d3545a1.tar.bz2 openbsd-fd7ba321fde0d383e365368c92e2b4fd7d3545a1.zip |
spaces found during a read
-rw-r--r-- | src/usr.bin/nc/netcat.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index 3909f70817..bbd8de0522 100644 --- a/src/usr.bin/nc/netcat.c +++ b/src/usr.bin/nc/netcat.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: netcat.c,v 1.133 2015/09/11 21:07:01 beck Exp $ */ | 1 | /* $OpenBSD: netcat.c,v 1.134 2015/09/11 21:22:54 deraadt Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> | 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> |
4 | * Copyright (c) 2015 Bob Beck. All rights reserved. | 4 | * Copyright (c) 2015 Bob Beck. All rights reserved. |
@@ -136,12 +136,12 @@ void set_common_sockopts(int, int); | |||
136 | int map_tos(char *, int *); | 136 | int map_tos(char *, int *); |
137 | int map_tls(char *, int *); | 137 | int map_tls(char *, int *); |
138 | void report_connect(const struct sockaddr *, socklen_t); | 138 | void report_connect(const struct sockaddr *, socklen_t); |
139 | void report_tls(struct tls * tls_ctx, char * host, char *tls_expectname); | 139 | void report_tls(struct tls *tls_ctx, char * host, char *tls_expectname); |
140 | void usage(int); | 140 | void usage(int); |
141 | ssize_t drainbuf(int, unsigned char *, size_t *, struct tls *); | 141 | ssize_t drainbuf(int, unsigned char *, size_t *, struct tls *); |
142 | ssize_t fillbuf(int, unsigned char *, size_t *, struct tls *); | 142 | ssize_t fillbuf(int, unsigned char *, size_t *, struct tls *); |
143 | void tls_setup_client(struct tls *, int, char *); | 143 | void tls_setup_client(struct tls *, int, char *); |
144 | struct tls * tls_setup_server(struct tls *, int, char *); | 144 | struct tls *tls_setup_server(struct tls *, int, char *); |
145 | 145 | ||
146 | int | 146 | int |
147 | main(int argc, char *argv[]) | 147 | main(int argc, char *argv[]) |
@@ -502,8 +502,7 @@ main(int argc, char *argv[]) | |||
502 | if (vflag) | 502 | if (vflag) |
503 | report_connect((struct sockaddr *)&cliaddr, len); | 503 | report_connect((struct sockaddr *)&cliaddr, len); |
504 | if ((usetls) && | 504 | if ((usetls) && |
505 | (tls_cctx = tls_setup_server(tls_ctx, connfd, | 505 | (tls_cctx = tls_setup_server(tls_ctx, connfd, host))) |
506 | host))) | ||
507 | readwrite(connfd, tls_cctx); | 506 | readwrite(connfd, tls_cctx); |
508 | if (!usetls) | 507 | if (!usetls) |
509 | readwrite(connfd, NULL); | 508 | readwrite(connfd, NULL); |
@@ -707,7 +706,7 @@ tls_setup_server(struct tls *tls_ctx, int connfd, char *host) | |||
707 | strcmp(tls_expecthash, tls_peerhash) != 0) | 706 | strcmp(tls_expecthash, tls_peerhash) != 0) |
708 | warnx("peer certificate is not %s", tls_expecthash); | 707 | warnx("peer certificate is not %s", tls_expecthash); |
709 | else if (gotcert && tls_expectname && | 708 | else if (gotcert && tls_expectname && |
710 | (! tls_peer_cert_contains_name(tls_cctx, tls_expectname))) | 709 | (!tls_peer_cert_contains_name(tls_cctx, tls_expectname))) |
711 | warnx("name (%s) not found in client cert", | 710 | warnx("name (%s) not found in client cert", |
712 | tls_expectname); | 711 | tls_expectname); |
713 | else { | 712 | else { |
@@ -957,8 +956,8 @@ readwrite(int net_fd, struct tls *tls_ctx) | |||
957 | 956 | ||
958 | while (1) { | 957 | while (1) { |
959 | /* both inputs are gone, buffers are empty, we are done */ | 958 | /* both inputs are gone, buffers are empty, we are done */ |
960 | if (pfd[POLL_STDIN].fd == -1 && pfd[POLL_NETIN].fd == -1 | 959 | if (pfd[POLL_STDIN].fd == -1 && pfd[POLL_NETIN].fd == -1 && |
961 | && stdinbufpos == 0 && netinbufpos == 0) { | 960 | stdinbufpos == 0 && netinbufpos == 0) { |
962 | close(net_fd); | 961 | close(net_fd); |
963 | return; | 962 | return; |
964 | } | 963 | } |
@@ -968,8 +967,8 @@ readwrite(int net_fd, struct tls *tls_ctx) | |||
968 | return; | 967 | return; |
969 | } | 968 | } |
970 | /* listen and net in gone, queues empty, done */ | 969 | /* listen and net in gone, queues empty, done */ |
971 | if (lflag && pfd[POLL_NETIN].fd == -1 | 970 | if (lflag && pfd[POLL_NETIN].fd == -1 && |
972 | && stdinbufpos == 0 && netinbufpos == 0) { | 971 | stdinbufpos == 0 && netinbufpos == 0) { |
973 | close(net_fd); | 972 | close(net_fd); |
974 | return; | 973 | return; |
975 | } | 974 | } |
@@ -1002,13 +1001,13 @@ readwrite(int net_fd, struct tls *tls_ctx) | |||
1002 | /* reading is possible after HUP */ | 1001 | /* reading is possible after HUP */ |
1003 | if (pfd[POLL_STDIN].events & POLLIN && | 1002 | if (pfd[POLL_STDIN].events & POLLIN && |
1004 | pfd[POLL_STDIN].revents & POLLHUP && | 1003 | pfd[POLL_STDIN].revents & POLLHUP && |
1005 | ! (pfd[POLL_STDIN].revents & POLLIN)) | 1004 | !(pfd[POLL_STDIN].revents & POLLIN)) |
1006 | pfd[POLL_STDIN].fd = -1; | 1005 | pfd[POLL_STDIN].fd = -1; |
1007 | 1006 | ||
1008 | if (pfd[POLL_NETIN].events & POLLIN && | 1007 | if (pfd[POLL_NETIN].events & POLLIN && |
1009 | pfd[POLL_NETIN].revents & POLLHUP && | 1008 | pfd[POLL_NETIN].revents & POLLHUP && |
1010 | ! (pfd[POLL_NETIN].revents & POLLIN)) | 1009 | !(pfd[POLL_NETIN].revents & POLLIN)) |
1011 | pfd[POLL_NETIN].fd = -1; | 1010 | pfd[POLL_NETIN].fd = -1; |
1012 | 1011 | ||
1013 | if (pfd[POLL_NETOUT].revents & POLLHUP) { | 1012 | if (pfd[POLL_NETOUT].revents & POLLHUP) { |
1014 | if (Nflag) | 1013 | if (Nflag) |
@@ -1411,7 +1410,7 @@ map_tos(char *s, int *val) | |||
1411 | { "netcontrol", IPTOS_PREC_NETCONTROL }, | 1410 | { "netcontrol", IPTOS_PREC_NETCONTROL }, |
1412 | { "reliability", IPTOS_RELIABILITY }, | 1411 | { "reliability", IPTOS_RELIABILITY }, |
1413 | { "throughput", IPTOS_THROUGHPUT }, | 1412 | { "throughput", IPTOS_THROUGHPUT }, |
1414 | { NULL, -1 }, | 1413 | { NULL, -1 }, |
1415 | }; | 1414 | }; |
1416 | 1415 | ||
1417 | for (t = toskeywords; t->keyword != NULL; t++) { | 1416 | for (t = toskeywords; t->keyword != NULL; t++) { |
@@ -1435,7 +1434,7 @@ map_tls(char *s, int *val) | |||
1435 | { "noverify", TLS_NOVERIFY }, | 1434 | { "noverify", TLS_NOVERIFY }, |
1436 | { "noname", TLS_NONAME }, | 1435 | { "noname", TLS_NONAME }, |
1437 | { "clientcert", TLS_CCERT}, | 1436 | { "clientcert", TLS_CCERT}, |
1438 | { NULL, -1 }, | 1437 | { NULL, -1 }, |
1439 | }; | 1438 | }; |
1440 | 1439 | ||
1441 | for (t = tlskeywords; t->keyword != NULL; t++) { | 1440 | for (t = tlskeywords; t->keyword != NULL; t++) { |
@@ -1474,10 +1473,10 @@ report_connect(const struct sockaddr *sa, socklen_t salen) | |||
1474 | char remote_port[NI_MAXSERV]; | 1473 | char remote_port[NI_MAXSERV]; |
1475 | int herr; | 1474 | int herr; |
1476 | int flags = NI_NUMERICSERV; | 1475 | int flags = NI_NUMERICSERV; |
1477 | 1476 | ||
1478 | if (nflag) | 1477 | if (nflag) |
1479 | flags |= NI_NUMERICHOST; | 1478 | flags |= NI_NUMERICHOST; |
1480 | 1479 | ||
1481 | if ((herr = getnameinfo(sa, salen, | 1480 | if ((herr = getnameinfo(sa, salen, |
1482 | remote_host, sizeof(remote_host), | 1481 | remote_host, sizeof(remote_host), |
1483 | remote_port, sizeof(remote_port), | 1482 | remote_port, sizeof(remote_port), |
@@ -1487,7 +1486,7 @@ report_connect(const struct sockaddr *sa, socklen_t salen) | |||
1487 | else | 1486 | else |
1488 | errx(1, "getnameinfo: %s", gai_strerror(herr)); | 1487 | errx(1, "getnameinfo: %s", gai_strerror(herr)); |
1489 | } | 1488 | } |
1490 | 1489 | ||
1491 | fprintf(stderr, | 1490 | fprintf(stderr, |
1492 | "Connection from %s %s " | 1491 | "Connection from %s %s " |
1493 | "received!\n", remote_host, remote_port); | 1492 | "received!\n", remote_host, remote_port); |