@matheusbsbs / matheus-bagliano / commits / 111dd25f3c
Fork 0

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>

Junio C Hamano committed Feb 11, 2008 at 10:57 UTC 111dd25f3c34ccad101047c32e89d1bb87136f60
1 file changed +15 -10
http.c
+15 -10
@@ -101,16 +101,18 @@ static int http_options(const char *var, const char *value)
101
102 if (!strcmp("http.sslcert", var)) {
103 if (ssl_cert == NULL) {
104 - ssl_cert = xmalloc(strlen(value)+1);
105 - strcpy(ssl_cert, value);
104 + if (!value)
105 + return config_error_nonbool(var);
106 + ssl_cert = xstrdup(value);
107 }
108 return 0;
109 }
110 #if LIBCURL_VERSION_NUM >= 0x070902
111 if (!strcmp("http.sslkey", var)) {
112 if (ssl_key == NULL) {
112 - ssl_key = xmalloc(strlen(value)+1);
113 - strcpy(ssl_key, value);
113 + if (!value)
114 + return config_error_nonbool(var);
115 + ssl_key = xstrdup(value);
116 }
117 return 0;
118 }
@@ -118,16 +120,18 @@ static int http_options(const char *var, const char *value)
120 #if LIBCURL_VERSION_NUM >= 0x070908
121 if (!strcmp("http.sslcapath", var)) {
122 if (ssl_capath == NULL) {
121 - ssl_capath = xmalloc(strlen(value)+1);
122 - strcpy(ssl_capath, value);
123 + if (!value)
124 + return config_error_nonbool(var);
125 + ssl_capath = xstrdup(value);
126 }
127 return 0;
128 }
129 #endif
130 if (!strcmp("http.sslcainfo", var)) {
131 if (ssl_cainfo == NULL) {
129 - ssl_cainfo = xmalloc(strlen(value)+1);
130 - strcpy(ssl_cainfo, value);
132 + if (!value)
133 + return config_error_nonbool(var);
134 + ssl_cainfo = xstrdup(value);
135 }
136 return 0;
137 }
@@ -157,8 +161,9 @@ static int http_options(const char *var, const char *value)
161 }
162 if (!strcmp("http.proxy", var)) {
163 if (curl_http_proxy == NULL) {
160 - curl_http_proxy = xmalloc(strlen(value)+1);
161 - strcpy(curl_http_proxy, value);
164 + if (!value)
165 + return config_error_nonbool(var);
166 + curl_http_proxy = xstrdup(value);
167 }
168 return 0;
169 }