Blame SOURCES/nmap-6.40-ncat_7.50.patch

41d651
diff --git a/ncat/ncat_connect.c b/ncat/ncat_connect.c
41d651
index a420126..048dc46 100644
41d651
--- a/ncat/ncat_connect.c
41d651
+++ b/ncat/ncat_connect.c
41d651
@@ -265,20 +265,20 @@ static void connect_report(nsock_iod nsi)
41d651
     union sockaddr_u peer;
41d651
     zmem(&peer, sizeof(peer.storage));
41d651
 
41d651
-    nsock_iod_get_communication_info(nsi, NULL, NULL, NULL, &peer.sockaddr,
41d651
+    nsi_getlastcommunicationinfo(nsi, NULL, NULL, NULL, &peer.sockaddr,
41d651
                                      sizeof(peer.storage));
41d651
     if (o.verbose) {
41d651
 #ifdef HAVE_OPENSSL
41d651
-        if (nsock_iod_check_ssl(nsi)) {
41d651
+        if (nsi_checkssl(nsi)) {
41d651
             X509 *cert;
41d651
             X509_NAME *subject;
41d651
             char digest_buf[SHA1_STRING_LENGTH + 1];
41d651
             char *fp;
41d651
 
41d651
             loguser("SSL connection to %s:%d.", inet_socktop(&peer),
41d651
-                    nsock_iod_get_peerport(nsi));
41d651
+                    nsi_peerport(nsi));
41d651
 
41d651
-            cert = SSL_get_peer_certificate((SSL *)nsock_iod_get_ssl(nsi));
41d651
+            cert = SSL_get_peer_certificate((SSL *)nsi_getssl(nsi));
41d651
             ncat_assert(cert != NULL);
41d651
 
41d651
             subject = X509_get_subject_name(cert);
41d651
@@ -303,7 +303,7 @@ static void connect_report(nsock_iod nsi)
41d651
             else
41d651
 #endif
41d651
                 loguser("Connected to %s:%d.\n", inet_socktop(&peer),
41d651
-                        nsock_iod_get_peerport(nsi));
41d651
+                        nsi_peerport(nsi));
41d651
         }
41d651
 #else
41d651
 #if HAVE_SYS_UN_H
41d651
@@ -312,7 +312,7 @@ static void connect_report(nsock_iod nsi)
41d651
         else
41d651
 #endif
41d651
             loguser("Connected to %s:%d.\n", inet_socktop(&peer),
41d651
-                    nsock_iod_get_peerport(nsi));
41d651
+                    nsi_peerport(nsi));
41d651
 #endif
41d651
     }
41d651
 }
41d651
@@ -892,32 +892,32 @@ int ncat_connect(void)
41d651
         nsock_set_default_engine("select");
41d651
 
41d651
     /* Create an nsock pool */
41d651
-    if ((mypool = nsock_pool_new(NULL)) == NULL)
41d651
+    if ((mypool = nsp_new(NULL)) == NULL)
41d651
         bye("Failed to create nsock_pool.");
41d651
 
41d651
     if (o.debug >= 6)
41d651
-        nsock_set_loglevel(NSOCK_LOG_DBG_ALL);
41d651
+        nsock_set_loglevel(mypool, NSOCK_LOG_DBG_ALL);
41d651
     else if (o.debug >= 3)
41d651
-        nsock_set_loglevel(NSOCK_LOG_DBG);
41d651
+        nsock_set_loglevel(mypool, NSOCK_LOG_DBG);
41d651
     else if (o.debug >= 1)
41d651
-        nsock_set_loglevel(NSOCK_LOG_INFO);
41d651
+        nsock_set_loglevel(mypool, NSOCK_LOG_INFO);
41d651
     else
41d651
-        nsock_set_loglevel(NSOCK_LOG_ERROR);
41d651
+        nsock_set_loglevel(mypool, NSOCK_LOG_ERROR);
41d651
 
41d651
     /* Allow connections to broadcast addresses. */
41d651
     nsock_pool_set_broadcast(mypool, 1);
41d651
 
41d651
 #ifdef HAVE_OPENSSL
41d651
-    set_ssl_ctx_options((SSL_CTX *) nsock_pool_ssl_init(mypool, 0));
41d651
+    set_ssl_ctx_options((SSL_CTX *) nsock_pool_ssl_init(mypool));
41d651
 #endif
41d651
 
41d651
     if (!o.proxytype) {
41d651
         /* A non-proxy connection. Create an iod for a new socket. */
41d651
-        cs.sock_nsi = nsock_iod_new(mypool, NULL);
41d651
+        cs.sock_nsi = nsi_new(mypool, NULL);
41d651
         if (cs.sock_nsi == NULL)
41d651
             bye("Failed to create nsock_iod.");
41d651
 
41d651
-        if (nsock_iod_set_hostname(cs.sock_nsi, o.target) == -1)
41d651
+        if (nsi_set_hostname(cs.sock_nsi, o.target) == -1)
41d651
             bye("Failed to set hostname on iod.");
41d651
 
41d651
 #if HAVE_SYS_UN_H
41d651
@@ -945,7 +945,7 @@ int ncat_connect(void)
41d651
                 strncpy(srcaddr.un.sun_path, tmp_name, sizeof(srcaddr.un.sun_path));
41d651
                 free (tmp_name);
41d651
             }
41d651
-            nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage,
41d651
+            nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage,
41d651
                                 SUN_LEN((struct sockaddr_un *)&srcaddr.storage));
41d651
 
41d651
             if (o.verbose)
41d651
@@ -957,23 +957,23 @@ int ncat_connect(void)
41d651
           case AF_UNSPEC:
41d651
             break;
41d651
           case AF_INET:
41d651
-            nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage,
41d651
+            nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage,
41d651
                                     sizeof(srcaddr.in));
41d651
             break;
41d651
 #ifdef AF_INET6
41d651
           case AF_INET6:
41d651
-            nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage,
41d651
+            nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage,
41d651
                                     sizeof(srcaddr.in6));
41d651
             break;
41d651
 #endif
41d651
 #if HAVE_SYS_UN_H
41d651
           case AF_UNIX:
41d651
-            nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage,
41d651
+            nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage,
41d651
                                     SUN_LEN((struct sockaddr_un *)&srcaddr.storage));
41d651
             break;
41d651
 #endif
41d651
           default:
41d651
-            nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage,
41d651
+            nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage,
41d651
                                     sizeof(srcaddr.storage));
41d651
             break;
41d651
         }
41d651
@@ -986,7 +986,7 @@ int ncat_connect(void)
41d651
                 bye("Sorry, -g can only currently be used with IPv4.");
41d651
             ipopts = buildsrcrte(targetaddrs->addr.in.sin_addr, o.srcrtes, o.numsrcrtes, o.srcrteptr, &ipoptslen);
41d651
 
41d651
-            nsock_iod_set_ipoptions(cs.sock_nsi, ipopts, ipoptslen);
41d651
+            nsi_set_ipoptions(cs.sock_nsi, ipopts, ipoptslen);
41d651
             free(ipopts); /* Nsock has its own copy */
41d651
         }
41d651
 
41d651
@@ -1029,10 +1029,10 @@ int ncat_connect(void)
41d651
 
41d651
         /* Once the proxy negotiation is done, Nsock takes control of the
41d651
            socket. */
41d651
-        cs.sock_nsi = nsock_iod_new2(mypool, connect_socket, NULL);
41d651
+        cs.sock_nsi = nsi_new2(mypool, connect_socket, NULL);
41d651
 
41d651
         /* Create IOD for nsp->stdin */
41d651
-        if ((cs.stdin_nsi = nsock_iod_new2(mypool, 0, NULL)) == NULL)
41d651
+        if ((cs.stdin_nsi = nsi_new2(mypool, 0, NULL)) == NULL)
41d651
             bye("Failed to create stdin nsiod.");
41d651
 
41d651
         post_connect(mypool, cs.sock_nsi);
41d651
@@ -1049,8 +1049,8 @@ int ncat_connect(void)
41d651
         gettimeofday(&end_time, NULL);
41d651
         time = TIMEVAL_MSEC_SUBTRACT(end_time, start_time) / 1000.0;
41d651
         loguser("%lu bytes sent, %lu bytes received in %.2f seconds.\n",
41d651
-            nsock_iod_get_write_count(cs.sock_nsi),
41d651
-            nsock_iod_get_read_count(cs.sock_nsi), time);
41d651
+            nsi_get_write_count(cs.sock_nsi),
41d651
+            nsi_get_read_count(cs.sock_nsi), time);
41d651
     }
41d651
 
41d651
 #if HAVE_SYS_UN_H
41d651
@@ -1061,7 +1061,7 @@ int ncat_connect(void)
41d651
     }
41d651
 #endif
41d651
 
41d651
-    nsock_pool_delete(mypool);
41d651
+    nsp_delete(mypool);
41d651
 
41d651
     return rc == NSOCK_LOOP_ERROR ? 1 : 0;
41d651
 }
41d651
@@ -1127,7 +1127,7 @@ static void connect_handler(nsock_pool nsp, nsock_event evt, void *data)
41d651
             if (o.verbose) {
41d651
                 union sockaddr_u peer;
41d651
                 zmem(&peer, sizeof(peer.storage));
41d651
-                nsock_iod_get_communication_info(cs.sock_nsi, NULL, NULL, NULL,
41d651
+                nsi_getlastcommunicationinfo(cs.sock_nsi, NULL, NULL, NULL,
41d651
                     &peer.sockaddr, sizeof(peer.storage));
41d651
                 loguser("Connection to %s failed: %s.\n", inet_socktop(&peer), socket_strerror(errcode));
41d651
                 loguser("Trying next address...\n");
41d651
@@ -1146,10 +1146,10 @@ static void connect_handler(nsock_pool nsp, nsock_event evt, void *data)
41d651
     }
41d651
 
41d651
 #ifdef HAVE_OPENSSL
41d651
-    if (nsock_iod_check_ssl(cs.sock_nsi)) {
41d651
+    if (nsi_checkssl(cs.sock_nsi)) {
41d651
         /* Check the domain name. ssl_post_connect_check prints an
41d651
            error message if appropriate. */
41d651
-        if (!ssl_post_connect_check((SSL *)nsock_iod_get_ssl(cs.sock_nsi), o.target))
41d651
+        if (!ssl_post_connect_check((SSL *)nsi_getssl(cs.sock_nsi), o.target))
41d651
             bye("Certificate verification error.");
41d651
     }
41d651
 #endif
41d651
@@ -1160,7 +1160,7 @@ static void connect_handler(nsock_pool nsp, nsock_event evt, void *data)
41d651
     }
41d651
 
41d651
     /* Create IOD for nsp->stdin */
41d651
-    if ((cs.stdin_nsi = nsock_iod_new2(nsp, 0, NULL)) == NULL)
41d651
+    if ((cs.stdin_nsi = nsi_new2(nsp, 0, NULL)) == NULL)
41d651
         bye("Failed to create stdin nsiod.");
41d651
 
41d651
     post_connect(nsp, nse_iod(evt));
41d651
@@ -1174,9 +1174,9 @@ static void post_connect(nsock_pool nsp, nsock_iod iod)
41d651
     if (o.cmdexec) {
41d651
         struct fdinfo info;
41d651
 
41d651
-        info.fd = nsock_iod_get_sd(iod);
41d651
+        info.fd = nsi_getsd(iod);
41d651
 #ifdef HAVE_OPENSSL
41d651
-        info.ssl = (SSL *)nsock_iod_get_ssl(iod);
41d651
+        info.ssl = (SSL *)nsi_getssl(iod);
41d651
 #endif
41d651
         /* Convert Nsock's non-blocking socket to an ordinary blocking one. It's
41d651
            possible for a program to write fast enough that it will get an
41d651
@@ -1217,7 +1217,7 @@ static void read_stdin_handler(nsock_pool nsp, nsock_event evt, void *data)
41d651
 
41d651
     if (status == NSE_STATUS_EOF) {
41d651
       if (!o.noshutdown)
41d651
-        shutdown(nsock_iod_get_sd(cs.sock_nsi), SHUT_WR);
41d651
+        shutdown(nsi_getsd(cs.sock_nsi), SHUT_WR);
41d651
         /* In --send-only mode or non-TCP mode, exit after EOF on stdin. */
41d651
         if (o.proto != IPPROTO_TCP || (o.proto == IPPROTO_TCP && o.sendonly))
41d651
             nsock_loop_quit(nsp);
41d651
@@ -1288,7 +1288,7 @@ static void read_socket_handler(nsock_pool nsp, nsock_event evt, void *data)
41d651
         ncat_delay_timer(o.linedelay);
41d651
 
41d651
     if (o.telnet)
41d651
-        dotelnet(nsock_iod_get_sd(nse_iod(evt)), (unsigned char *) buf, nbytes);
41d651
+        dotelnet(nsi_getsd(nse_iod(evt)), (unsigned char *) buf, nbytes);
41d651
 
41d651
     /* Write socket data to stdout */
41d651
     Write(STDOUT_FILENO, buf, nbytes);
41d651
diff --git a/ncat/util.h b/ncat/util.h
41d651
index 63f4c6f..f81d577 100644
41d651
--- a/ncat/util.h
41d651
+++ b/ncat/util.h
41d651
@@ -175,6 +175,8 @@ do { \
41d651
 
41d651
 void die(char *);
41d651
 
41d651
+#define NORETURN __attribute__((noreturn))
41d651
+
41d651
 NORETURN void bye(const char *, ...)
41d651
      __attribute__ ((format (printf, 1, 2)));
41d651
 
41d651
diff --git a/ncat/ncat_connect.c b/ncat/ncat_connect.c
41d651
index 048dc46..8680278 100644
41d651
--- a/ncat/ncat_connect.c
41d651
+++ b/ncat/ncat_connect.c
41d651
@@ -905,10 +905,10 @@ int ncat_connect(void)
41d651
         nsock_set_loglevel(mypool, NSOCK_LOG_ERROR);
41d651
 
41d651
     /* Allow connections to broadcast addresses. */
41d651
-    nsock_pool_set_broadcast(mypool, 1);
41d651
+    nsp_setbroadcast(mypool, 1);
41d651
 
41d651
 #ifdef HAVE_OPENSSL
41d651
-    set_ssl_ctx_options((SSL_CTX *) nsock_pool_ssl_init(mypool));
41d651
+    set_ssl_ctx_options((SSL_CTX *) nsp_ssl_init(mypool));
41d651
 #endif
41d651
 
41d651
     if (!o.proxytype) {