+ errstr = "buffer cbuf too small.";
+ log_error(LOG_LEVEL_CONNECT, "socks4_connect: %s", errstr);
+ err = 1;
+ }
+ else
+ {
+ strlcpy(buf + csiz, target_host, sizeof(buf) - sizeof(struct socks_op) - csiz);
+ /*
+ * What we forward to the socks4a server should have the
+ * size of socks_op, plus the length of the userid plus
+ * its \0 byte (which we don't have to add because the
+ * first byte of the userid is counted twice as it's also
+ * part of sock_op) minus the padding bytes (which are part
+ * of the userid as well), plus the length of the target_host
+ * (which is stored csiz bytes after the beginning of the buffer),
+ * plus another \0 byte.
+ */
+ assert(n == sizeof(struct socks_op) + strlen(&(c->userid)) - sizeof(c->padding) + strlen(buf + csiz) + 1);
+ csiz = n;