diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-02-11 10:57:22 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-02-11 13:11:37 -0800 |
commit | 111dd25f3c34ccad101047c32e89d1bb87136f60 (patch) | |
tree | 0bdd6a9c2e94019ec3051b4ad01d06c0c3bbe51c | |
parent | help.c: guard config parser from value=NULL (diff) | |
download | tgif-111dd25f3c34ccad101047c32e89d1bb87136f60.tar.xz |
http.c: guard config parser from value=NULL
http.sslcert and friends expect a string value
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | http.c | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -101,16 +101,18 @@ static int http_options(const char *var, const char *value) if (!strcmp("http.sslcert", var)) { if (ssl_cert == NULL) { - ssl_cert = xmalloc(strlen(value)+1); - strcpy(ssl_cert, value); + if (!value) + return config_error_nonbool(var); + ssl_cert = xstrdup(value); } return 0; } #if LIBCURL_VERSION_NUM >= 0x070902 if (!strcmp("http.sslkey", var)) { if (ssl_key == NULL) { - ssl_key = xmalloc(strlen(value)+1); - strcpy(ssl_key, value); + if (!value) + return config_error_nonbool(var); + ssl_key = xstrdup(value); } return 0; } @@ -118,16 +120,18 @@ static int http_options(const char *var, const char *value) #if LIBCURL_VERSION_NUM >= 0x070908 if (!strcmp("http.sslcapath", var)) { if (ssl_capath == NULL) { - ssl_capath = xmalloc(strlen(value)+1); - strcpy(ssl_capath, value); + if (!value) + return config_error_nonbool(var); + ssl_capath = xstrdup(value); } return 0; } #endif if (!strcmp("http.sslcainfo", var)) { if (ssl_cainfo == NULL) { - ssl_cainfo = xmalloc(strlen(value)+1); - strcpy(ssl_cainfo, value); + if (!value) + return config_error_nonbool(var); + ssl_cainfo = xstrdup(value); } return 0; } @@ -157,8 +161,9 @@ static int http_options(const char *var, const char *value) } if (!strcmp("http.proxy", var)) { if (curl_http_proxy == NULL) { - curl_http_proxy = xmalloc(strlen(value)+1); - strcpy(curl_http_proxy, value); + if (!value) + return config_error_nonbool(var); + curl_http_proxy = xstrdup(value); } return 0; } |