aboutsummaryrefslogtreecommitdiff
path: root/lib/socks.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-04-24 12:40:00 +0200
committerDaniel Stenberg <daniel@haxx.se>2010-04-24 12:40:00 +0200
commit7fb7f2413194e7f7a21716f86c765ad47c66fadf (patch)
tree015263dba2b1691259cd8fface43798c1a806b1f /lib/socks.c
parent5b40c11c2f3db2f4de4969ebabca45b42ad405cc (diff)
socks5: please static code analyzer
Make sure we don't call memcpy() if the argument is NULL even though we also passed a zero length then, as the clang analyzer whined and we want to limit warnings (even false positives) when they're this easy to fix. The change of (char) to (unsigned char) will fix long user names and passwords on systems that have the char type signed by default.
Diffstat (limited to 'lib/socks.c')
-rw-r--r--lib/socks.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/socks.c b/lib/socks.c
index df301ecec..9787f864a 100644
--- a/lib/socks.c
+++ b/lib/socks.c
@@ -511,11 +511,13 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
*/
len = 0;
socksreq[len++] = 1; /* username/pw subnegotiation version */
- socksreq[len++] = (char) userlen;
- memcpy(socksreq + len, proxy_name, userlen);
+ socksreq[len++] = (unsigned char) userlen;
+ if(proxy_name && userlen)
+ memcpy(socksreq + len, proxy_name, userlen);
len += (int)userlen;
- socksreq[len++] = (char) pwlen;
- memcpy(socksreq + len, proxy_password, pwlen);
+ socksreq[len++] = (unsigned char) pwlen;
+ if(proxy_password && pwlen)
+ memcpy(socksreq + len, proxy_password, pwlen);
len += (int)pwlen;
code = Curl_write_plain(conn, sock, (char *)socksreq, len, &written);