=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/nc/netcat.c,v retrieving revision 1.153 retrieving revision 1.154 diff -c -r1.153 -r1.154 *** src/usr.bin/nc/netcat.c 2016/06/02 04:26:32 1.153 --- src/usr.bin/nc/netcat.c 2016/06/27 23:58:08 1.154 *************** *** 1,4 **** ! /* $OpenBSD: netcat.c,v 1.153 2016/06/02 04:26:32 beck Exp $ */ /* * Copyright (c) 2001 Eric Jackson * Copyright (c) 2015 Bob Beck. All rights reserved. --- 1,4 ---- ! /* $OpenBSD: netcat.c,v 1.154 2016/06/27 23:58:08 deraadt Exp $ */ /* * Copyright (c) 2001 Eric Jackson * Copyright (c) 2015 Bob Beck. All rights reserved. *************** *** 144,150 **** int main(int argc, char *argv[]) { ! int ch, s, ret, socksv; char *host, *uport; struct addrinfo hints; struct servent *sv; --- 144,150 ---- int main(int argc, char *argv[]) { ! int ch, s = -1, ret, socksv; char *host, *uport; struct addrinfo hints; struct servent *sv; *************** *** 158,164 **** struct tls *tls_ctx = NULL; ret = 1; - s = 0; socksv = 5; host = NULL; uport = NULL; --- 158,163 ---- *************** *** 586,593 **** build_ports(uport); /* Cycle through portlist, connecting to each port. */ ! for (i = 0; portlist[i] != NULL; i++) { ! if (s) close(s); if (usetls) { --- 585,592 ---- build_ports(uport); /* Cycle through portlist, connecting to each port. */ ! for (s = -1, i = 0; portlist[i] != NULL; i++) { ! if (s != -1) close(s); if (usetls) { *************** *** 604,610 **** else s = remote_connect(host, portlist[i], hints); ! if (s < 0) continue; ret = 0; --- 603,609 ---- else s = remote_connect(host, portlist[i], hints); ! if (s == -1) continue; ret = 0; *************** *** 653,659 **** } } ! if (s) close(s); tls_config_free(tls_cfg); --- 652,658 ---- } } ! if (s != -1) close(s); tls_config_free(tls_cfg);