Skip to content
Permalink
Browse files

tool_getparam: Fix C90 violations

  • Loading branch information
bbakersmith committed Feb 14, 2020
1 parent 17a1558 commit 34a9d4aa08d1ad20f9764186d9345fc6e9fe22d3
Showing with 16 additions and 7 deletions.
  1. +16 −7 src/tool_getparam.c
@@ -529,15 +529,18 @@ static char *replace_url_encoded_space_with_plus(const char *in)

static char *escape_form_urlencoded_string(const char *in, size_t inlen)
{
char *enc;
char *out;

if(inlen == 0)
return strdup(""); /* if no input, return empty string */

char *enc = curl_easy_escape(NULL, in, (int)inlen);
enc = curl_easy_escape(NULL, in, (int)inlen);
if(!enc)
return NULL;

/* escape spaces per RFC1866 */
char *out = replace_url_encoded_space_with_plus(enc);
out = replace_url_encoded_space_with_plus(enc);
curl_free(enc);
if(!out)
return NULL;
@@ -1432,23 +1435,29 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
}
else {
/* encode the content */
char *encvalue = escape_form_urlencoded_string(postdata, size);
char *encvalue;
char *encname;
size_t encnamelen;
size_t outlen;
char *n;

encvalue = escape_form_urlencoded_string(postdata, size);
Curl_safefree(postdata); /* no matter if it worked or not */
if(!encvalue)
return PARAM_NO_MEM;

/* encode the name */
char *encname = escape_form_urlencoded_string(nextarg, nlen);
encname = escape_form_urlencoded_string(nextarg, nlen);
if(!encname) {
curl_free(encvalue);
return PARAM_NO_MEM;
}

size_t encnamelen = strlen(encname);
encnamelen = strlen(encname);

/* create the final encoded string */
size_t outlen = encnamelen + strlen(encvalue) + 2;
char *n = malloc(outlen);
outlen = encnamelen + strlen(encvalue) + 2;
n = malloc(outlen);
if(!n) {
curl_free(encvalue);
curl_free(encname);

0 comments on commit 34a9d4a

Please sign in to comment.
You can’t perform that action at this time.