提交 111dd25f 编写于 作者: J Junio C Hamano

http.c: guard config parser from value=NULL

http.sslcert and friends expect a string value
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 b51b2bb4
...@@ -101,16 +101,18 @@ static int http_options(const char *var, const char *value) ...@@ -101,16 +101,18 @@ static int http_options(const char *var, const char *value)
if (!strcmp("http.sslcert", var)) { if (!strcmp("http.sslcert", var)) {
if (ssl_cert == NULL) { if (ssl_cert == NULL) {
ssl_cert = xmalloc(strlen(value)+1); if (!value)
strcpy(ssl_cert, value); return config_error_nonbool(var);
ssl_cert = xstrdup(value);
} }
return 0; return 0;
} }
#if LIBCURL_VERSION_NUM >= 0x070902 #if LIBCURL_VERSION_NUM >= 0x070902
if (!strcmp("http.sslkey", var)) { if (!strcmp("http.sslkey", var)) {
if (ssl_key == NULL) { if (ssl_key == NULL) {
ssl_key = xmalloc(strlen(value)+1); if (!value)
strcpy(ssl_key, value); return config_error_nonbool(var);
ssl_key = xstrdup(value);
} }
return 0; return 0;
} }
...@@ -118,16 +120,18 @@ static int http_options(const char *var, const char *value) ...@@ -118,16 +120,18 @@ static int http_options(const char *var, const char *value)
#if LIBCURL_VERSION_NUM >= 0x070908 #if LIBCURL_VERSION_NUM >= 0x070908
if (!strcmp("http.sslcapath", var)) { if (!strcmp("http.sslcapath", var)) {
if (ssl_capath == NULL) { if (ssl_capath == NULL) {
ssl_capath = xmalloc(strlen(value)+1); if (!value)
strcpy(ssl_capath, value); return config_error_nonbool(var);
ssl_capath = xstrdup(value);
} }
return 0; return 0;
} }
#endif #endif
if (!strcmp("http.sslcainfo", var)) { if (!strcmp("http.sslcainfo", var)) {
if (ssl_cainfo == NULL) { if (ssl_cainfo == NULL) {
ssl_cainfo = xmalloc(strlen(value)+1); if (!value)
strcpy(ssl_cainfo, value); return config_error_nonbool(var);
ssl_cainfo = xstrdup(value);
} }
return 0; return 0;
} }
...@@ -157,8 +161,9 @@ static int http_options(const char *var, const char *value) ...@@ -157,8 +161,9 @@ static int http_options(const char *var, const char *value)
} }
if (!strcmp("http.proxy", var)) { if (!strcmp("http.proxy", var)) {
if (curl_http_proxy == NULL) { if (curl_http_proxy == NULL) {
curl_http_proxy = xmalloc(strlen(value)+1); if (!value)
strcpy(curl_http_proxy, value); return config_error_nonbool(var);
curl_http_proxy = xstrdup(value);
} }
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册