changeset 572:6d2d3b512750

Remove linefeeds from the th_network message strings.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 09 Jan 2020 13:48:58 +0200
parents 423a8ace2598
children 7c0aa6bf484a
files th_network.c
diffstat 1 files changed, 38 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/th_network.c	Thu Jan 09 13:48:17 2020 +0200
+++ b/th_network.c	Thu Jan 09 13:48:58 2020 +0200
@@ -101,12 +101,12 @@
     {
         int err = th_errno_to_error(h_errno);
         th_conn_err(conn, err,
-            "Could not resolve hostname '%s': %s\n",
+            "Could not resolve hostname '%s': %s",
             name, th_error_str(err));
     }
     else
     {
-        th_conn_msg(conn, THLOG_INFO, "True hostname for %s is %s\n",
+        th_conn_msg(conn, THLOG_INFO, "True hostname for %s is %s",
             name, res->h_name);
     }
 
@@ -241,7 +241,7 @@
         switch (status = th_conn_pull(conn))
         {
             case TH_CONN_ERROR:
-                th_conn_err(conn, status, "Proxy negotiation failed at try %d with network error: %s.\n",
+                th_conn_err(conn, status, "Proxy negotiation failed at try %d with network error: %s",
                     tries, th_error_str(conn->err));
                 break;
 
@@ -257,7 +257,7 @@
     }
 
     if (status != TH_CONN_DATA_AVAIL)
-        th_conn_err(conn, THERR_TIMED_OUT, "Proxy negotiation timed out.\n");
+        th_conn_err(conn, THERR_TIMED_OUT, "Proxy negotiation timed out.");
 
     return status;
 }
@@ -278,7 +278,7 @@
 
     (void) host;
     th_growbuf_init(&buf, 128);
-    th_conn_msg(conn, THLOG_INFO, "Initializing SOCKS 4/a proxy negotiation.\n");
+    th_conn_msg(conn, THLOG_INFO, "Initializing SOCKS 4/a proxy negotiation.");
 
     switch (conn->proxy.mode)
     {
@@ -286,7 +286,7 @@
         case TH_PROXY_CMD_BIND: cmd = 2; break;
         default:
             err = THERR_NOT_SUPPORTED;
-            th_conn_err(conn, err, "Invalid SOCKS 4 command/mode, unsupported.\n");
+            th_conn_err(conn, err, "Invalid SOCKS 4 command/mode, unsupported.");
             goto out;
     }
 
@@ -308,7 +308,8 @@
             {
                 err = THERR_INIT_FAIL;
                 th_conn_err(conn, err,
-                    "Invalid proxy settings, SOCKS 4 in use, but domain address type requested. SOCKS 4a or 5 required for host atype.\n");
+                    "Invalid proxy settings, SOCKS 4 in use, but domain "
+                    "address type requested. SOCKS 4a or 5 required for host atype.");
                 goto out;
             }
             break;
@@ -316,7 +317,7 @@
         default:
             err = THERR_INIT_FAIL;
             th_conn_err(conn, err,
-                "Invalid proxy settings for SOCKS 4, unsupported address type requested.\n");
+                "Invalid proxy settings for SOCKS 4, unsupported address type requested.");
             goto out;
     }
 
@@ -337,7 +338,7 @@
     {
         err = THERR_INIT_FAIL;
         th_conn_err(conn, err,
-            "Invalid SOCKS 4 server reply, does not begin with NUL byte (%d).\n",
+            "Invalid SOCKS 4 server reply, does not begin with NUL byte (0x%02x).",
             *ptr);
         goto out;
     }
@@ -355,7 +356,7 @@
         }
 
         err = THERR_INIT_FAIL;
-        th_conn_err(conn, err, "SOCKS 4 setup failed, 0x%02x: %s.\n", *ptr, s);
+        th_conn_err(conn, err, "SOCKS 4 setup failed, 0x%02x: %s", *ptr, s);
         goto out;
     }
 
@@ -374,7 +375,7 @@
     int i, cmd, avail, auth, err = THERR_INIT_FAIL;
 
     th_growbuf_init(&buf, 256);
-    th_conn_msg(conn, THLOG_INFO, "Initializing SOCKS 5 proxy negotiation.\n");
+    th_conn_msg(conn, THLOG_INFO, "Initializing SOCKS 5 proxy negotiation.");
 
     switch (conn->proxy.mode)
     {
@@ -383,7 +384,7 @@
         case TH_PROXY_CMD_ASSOC_UDP: cmd = 3; break;
         default:
             err = THERR_NOT_SUPPORTED;
-            th_conn_err(conn, err, "Invalid SOCKS 5 command/mode, unsupported.\n");
+            th_conn_err(conn, err, "Invalid SOCKS 5 command/mode, unsupported.");
             goto out;
     }
 
@@ -396,7 +397,7 @@
             {
                 err = THERR_INVALID_DATA;
                 th_conn_err(conn, err,
-                    "SOCKS 5 user authentication chosen, but no user/pass set.\n");
+                    "SOCKS 5 user authentication chosen, but no user/pass set.");
                 goto out;
             }
 
@@ -405,7 +406,7 @@
             {
                 err = THERR_INVALID_DATA;
                 th_conn_err(conn, err,
-                    "SOCKS 5 proxy userid or password is too long.\n");
+                    "SOCKS 5 proxy userid or password is too long.");
                 goto out;
             }
             // Intentionally fallthrough
@@ -417,7 +418,7 @@
         default:
             err = THERR_NOT_SUPPORTED;
             th_conn_err(conn, err,
-                "Unsupported proxy authentication method %d.\n",
+                "Unsupported proxy authentication method %d.",
                 conn->proxy.auth_type);
             goto out;
     }
@@ -442,7 +443,7 @@
     {
         err = THERR_INVALID_DATA;
         th_conn_err(conn, err,
-            "Invalid SOCKS 5 server reply, does not begin with protocol version byte (%d).\n", *ptr);
+            "Invalid SOCKS 5 server reply, does not begin with protocol version byte (%d).", *ptr);
         goto out;
     }
     ptr++;
@@ -452,14 +453,14 @@
     {
         err = THERR_NOT_SUPPORTED;
         th_conn_err(conn, err,
-            "No authentication method could be negotiated with the server.\n");
+            "No authentication method could be negotiated with the server.");
         goto out;
     }
     else
     if (auth == SOCKS5_AUTH_USER)
     {
         // Attempt user/pass authentication (RFC 1929)
-        th_conn_msg(conn, THLOG_INFO, "Attempting SOCKS 5 user/pass authentication.\n");
+        th_conn_msg(conn, THLOG_INFO, "Attempting SOCKS 5 user/pass authentication.");
         th_growbuf_clear(&buf);
 
         th_growbuf_put_u8(&buf, 0x01);
@@ -481,7 +482,7 @@
         {
             err = THERR_INVALID_DATA;
             th_conn_err(conn, err,
-                "Invalid SOCKS 5 server reply, does not begin with protocol version byte (%d).\n", *ptr);
+                "Invalid SOCKS 5 server reply, does not begin with protocol version byte (0x%02x).", *ptr);
             goto out;
         }
         ptr++;
@@ -489,20 +490,20 @@
         {
             err = THERR_AUTH_FAILED;
             th_conn_err(conn, err,
-                "SOCKS 5 proxy user/pass authentication failed! Code 0x%02x.\n", *ptr);
+                "SOCKS 5 proxy user/pass authentication failed! Code 0x%02x.", *ptr);
             goto out;
         }
     }
     else
     if (auth == SOCKS5_AUTH_NONE)
     {
-        th_conn_msg(conn, THLOG_INFO, "Using no authentication for SOCKS 5.\n");
+        th_conn_msg(conn, THLOG_INFO, "Using no authentication for SOCKS 5.");
     }
     else
     {
         err = THERR_NOT_SUPPORTED;
         th_conn_err(conn, err,
-            "Proxy server chose an unsupported SOCKS 5 authentication method 0x%02x.\n",
+            "Proxy server chose an unsupported SOCKS 5 authentication method 0x%02x.",
             auth);
         goto out;
     }
@@ -532,7 +533,7 @@
             {
                 err = THERR_NOT_SUPPORTED;
                 th_conn_err(conn, err,
-                    "Domain address type requested, but domain name longer than 255 characters (%d).\n", cmd);
+                    "Domain address type requested, but domain name longer than 255 characters (%d).", cmd);
                 goto out;
             }
 
@@ -557,7 +558,7 @@
     {
         err = THERR_INVALID_DATA;
         th_conn_err(conn, err,
-            "Invalid SOCKS 5 server reply, does not begin with protocol version byte (%d).\n", *ptr);
+            "Invalid SOCKS 5 server reply, does not begin with protocol version byte (%d).", *ptr);
         goto out;
     }
     ptr++;
@@ -565,16 +566,16 @@
     {
         err = THERR_INIT_FAIL;
         if (*ptr < th_socks5_results_msgs_num)
-            th_conn_err(conn, err, "SOCKS 5 error: %s.\n", th_socks5_results_msgs[*ptr]);
+            th_conn_err(conn, err, "SOCKS 5 error: %s.", th_socks5_results_msgs[*ptr]);
         else
-            th_conn_err(conn, err, "Unknown SOCKS 5 result code 0x%02x.\n", *ptr);
+            th_conn_err(conn, err, "Unknown SOCKS 5 result code 0x%02x.", *ptr);
         goto out;
     }
     ptr++;
     if (*ptr != 0)
     {
         err = THERR_INVALID_DATA;
-        th_conn_err(conn, err, "Invalid reply from SOCKS 5 server: expected 0x00, got 0x%02x.\n", *ptr);
+        th_conn_err(conn, err, "Invalid reply from SOCKS 5 server: expected 0x00, got 0x%02x.", *ptr);
         goto out;
     }
 
@@ -613,7 +614,7 @@
         dest.sin_port = htons(conn->proxy.conn.port);
         dest.sin_addr = conn->proxy.conn.addr;
 
-        th_conn_msg(conn, THLOG_INFO, "Connecting to %s proxy %s:%d ...\n",
+        th_conn_msg(conn, THLOG_INFO, "Connecting to %s proxy %s:%d ...",
             th_proxy_types[conn->proxy.type],
             inet_ntoa(conn->proxy.conn.addr), conn->proxy.conn.port);
     }
@@ -622,21 +623,21 @@
         dest.sin_port = htons(conn->base.port);
         dest.sin_addr = conn->base.addr;
 
-        th_conn_msg(conn, THLOG_INFO, "Connecting to %s:%d ...\n",
+        th_conn_msg(conn, THLOG_INFO, "Connecting to %s:%d ...",
             inet_ntoa(conn->base.addr), conn->base.port);
     }
 
     if ((conn->base.socket = socket(PF_INET, SOCK_STREAM, 0)) == -1)
     {
         err = th_errno_to_error(th_get_socket_errno());
-        th_conn_err(conn, err, "Could not open socket: %s\n", th_error_str(err));
+        th_conn_err(conn, err, "Could not open socket: %s", th_error_str(err));
         goto error;
     }
 
     if (connect(conn->base.socket, (struct sockaddr *) &dest, sizeof(dest)) == -1)
     {
         err = th_errno_to_error(th_get_socket_errno());
-        th_conn_err(conn, err, "Could not connect: %s\n", th_error_str(err));
+        th_conn_err(conn, err, "Could not connect: %s", th_error_str(err));
         goto error;
     }
 
@@ -650,13 +651,13 @@
         case TH_PROXY_SOCKS4A:
             if ((err = th_conn_socks4_negotiate(conn, port, host)) != THERR_OK)
                 goto error;
-            th_conn_msg(conn, THLOG_INFO, "SOCKS 4 connection established!\n");
+            th_conn_msg(conn, THLOG_INFO, "SOCKS 4 connection established!");
             break;
 
         case TH_PROXY_SOCKS5:
             if ((err = th_conn_socks5_negotiate(conn, port, host)) != THERR_OK)
                 goto error;
-            th_conn_msg(conn, THLOG_INFO, "SOCKS 5 connection established!\n");
+            th_conn_msg(conn, THLOG_INFO, "SOCKS 5 connection established!");
             break;
     }
 
@@ -794,7 +795,7 @@
         if (err != EINTR)
         {
             err = th_errno_to_error(err);
-            th_conn_err(conn, err, "Error occured in select(%d, sockfds): %s\n",
+            th_conn_err(conn, err, "Error occured in select(%d, sockfds): %s",
                 conn->base.socket + 1, th_error_str(err));
             return TH_CONN_ERROR;
         }
@@ -807,12 +808,12 @@
         if (conn->base.got_bytes < 0)
         {
             int err = th_errno_to_error(th_get_socket_errno());
-            th_conn_err(conn, err, "Error in recv: %s\n", th_error_str(err));
+            th_conn_err(conn, err, "Error in recv: %s", th_error_str(err));
             return TH_CONN_ERROR;
         }
         else if (conn->base.got_bytes == 0)
         {
-            th_conn_err(conn, ECONNABORTED, "Server closed connection.\n");
+            th_conn_err(conn, ECONNABORTED, "Server closed connection.");
             conn->status = TH_CONN_CLOSED;
             return TH_CONN_CLOSED;
         }
@@ -845,7 +846,7 @@
     int err = WSAStartup(0x0101, &wsaData);
     if (err != 0)
     {
-        THERR("Could not initialize WinSock library (err=%d).\n", err);
+        THERR("Could not initialize WinSock library (err=%d).", err);
         return THERR_INIT_FAIL;
     }
 #endif