Fix bad zero-termination bug in the socket string formatter.

This created, among other things, malformed CONNECT proxy requests,
depending on the state of the stack
diff --git a/sockets.c b/sockets.c
index 2e61d9a..338b176 100644
--- a/sockets.c
+++ b/sockets.c
@@ -255,11 +255,14 @@
 static char*
 format_char( char*  buf, char*  end, int  c )
 {
-    if (buf >= end)
-        return buf;
-    if (buf+1 == end)
-        c = 0;
-    *buf++ = (char) c;
+    if (buf < end) {
+        if (buf+1 == end) {
+            *buf++ = 0;
+        } else {
+            *buf++ = (char) c;
+            *buf    = 0;
+        }
+    }
     return buf;
 }
 
@@ -350,7 +353,7 @@
 sock_address_to_string( const SockAddress*  a )
 {
     static char buf0[MAX_PATH];
-    char       *buf = buf0, *end = buf + sizeof(buf0);
+    char *buf = buf0, *end = buf + sizeof(buf0);
 
     switch (a->family) {
     case SOCKET_INET: