X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=packages%2FOS400%2Fccsidcurl.c;h=34ca8dc2345a75872c80b561551a89b143793e9d;hb=867eb33477c07331e7b58302119308d02a02ee01;hp=d0e6827b7fce5814ff721a85a26661c285a96fa5;hpb=32de14ae0782822e9c54c3fbb28cdefc1f4de969;p=platform%2Fupstream%2Fcurl.git diff --git a/packages/OS400/ccsidcurl.c b/packages/OS400/ccsidcurl.c index d0e6827..34ca8dc 100644 --- a/packages/OS400/ccsidcurl.c +++ b/packages/OS400/ccsidcurl.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -167,6 +167,7 @@ dynconvert(int dccsid, const char * s, int slen, int sccsid) char * cp; size_t dlen; int l; + int l2; static const char nullbyte = 0; /* Like convert, but the destination is allocated and returned. */ @@ -190,7 +191,7 @@ dynconvert(int dccsid, const char * s, int slen, int sccsid) Since destination code size is unknown, use a conversion to generate terminator. */ - int l2 = convert(d + l, dlen - l, dccsid, &nullbyte, -1, ASCII_CCSID); + l2 = convert(d + l, dlen - l, dccsid, &nullbyte, -1, ASCII_CCSID); if(l2 < 0) { free(d); @@ -216,11 +217,10 @@ slist_convert(int dccsid, struct curl_slist * from, int sccsid) { struct curl_slist * to = (struct curl_slist *) NULL; + char * cp; for(; from; from = from->next) { - char * cp = dynconvert(dccsid, from->data, -1, sccsid); - - if(!cp) { + if(!(cp = dynconvert(dccsid, from->data, -1, sccsid))) { curl_slist_free_all(to); return (struct curl_slist *) NULL; } @@ -269,7 +269,7 @@ curl_easy_escape_ccsid(CURL * handle, const char * string, int length, return (char *) NULL; } - s = dynconvert(ASCII_CCSID, string, length? length: -1, sccsid); + s = dynconvert(ASCII_CCSID, s, length? length: -1, sccsid); if(!s) return (char *) NULL; @@ -300,7 +300,7 @@ curl_easy_unescape_ccsid(CURL * handle, const char * string, int length, return (char *) NULL; } - s = dynconvert(ASCII_CCSID, string, length? length: -1, sccsid); + s = dynconvert(ASCII_CCSID, s, length? length: -1, sccsid); if(!s) return (char *) NULL; @@ -370,13 +370,15 @@ convert_version_info_string(const char * * stringp, char * * bufp, int * left, unsigned int ccsid) { + int l; + /* Helper for curl_version_info_ccsid(): convert a string if defined. Result is stored in the `*left'-byte buffer at `*bufp'. `*bufp' and `*left' are updated accordingly. Return 0 if ok, else -1. */ if(*stringp) { - int l = convert(*bufp, *left, ccsid, *stringp, -1, ASCII_CCSID); + l = convert(*bufp, *left, ccsid, *stringp, -1, ASCII_CCSID); if(l <= 0) return -1; @@ -398,6 +400,7 @@ curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid) char * cp; int n; int nproto; + int i; curl_version_info_data * id; /* The assertion below is possible, because although the second operand @@ -470,9 +473,8 @@ curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid) memcpy((char *) id, (char *) p, sizeof *p); if(id->protocols) { - int i = nproto * sizeof id->protocols[0]; - id->protocols = (const char * const *) cp; + i = nproto * sizeof id->protocols[0]; memcpy(cp, (char *) p->protocols, i); cp += i; n -= i; @@ -587,11 +589,11 @@ void curl_certinfo_free_all(struct curl_certinfo *info) { + int i; + /* Free all memory used by certificate info. */ if(info) { if(info->certinfo) { - int i; - for(i = 0; i < info->num_of_certs; i++) curl_slist_free_all(info->certinfo[i]); free((char *) info->certinfo); @@ -610,10 +612,13 @@ curl_easy_getinfo_ccsid(CURL * curl, CURLINFO info, ...) CURLcode ret; unsigned int ccsid; char * * cpp; + char * s; + char * d; struct SessionHandle * data; struct curl_slist * * slp; struct curl_certinfo * cipf; struct curl_certinfo * cipt; + int i; /* WARNING: unlike curl_easy_get_info(), the strings returned by this procedure have to be free'ed. */ @@ -629,11 +634,13 @@ curl_easy_getinfo_ccsid(CURL * curl, CURLINFO info, ...) case CURLINFO_STRING: ccsid = va_arg(arg, unsigned int); cpp = (char * *) paramp; + s = *cpp; - if(*cpp) { - *cpp = dynconvert(ccsid, *cpp, -1, ASCII_CCSID); + if(s) { + d = dynconvert(ccsid, s, -1, ASCII_CCSID); + *cpp = d; - if(!*cpp) + if(!d) ret = CURLE_OUT_OF_MEMORY; } @@ -654,8 +661,6 @@ curl_easy_getinfo_ccsid(CURL * curl, CURLINFO info, ...) if(!cipt->certinfo) ret = CURLE_OUT_OF_MEMORY; else { - int i; - cipt->num_of_certs = cipf->num_of_certs; for(i = 0; i < cipf->num_of_certs; i++) if(cipf->certinfo[i]) @@ -1102,6 +1107,7 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...) char * s; char * cp; unsigned int ccsid; + size_t len; curl_off_t pfsize; static char testwarn = 1; @@ -1114,8 +1120,7 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...) if(testwarn) { testwarn = 0; - if((int) STRING_LASTZEROTERMINATED != (int) STRING_UNIX_SOCKET_PATH + 1 || - (int) STRING_LAST != (int) STRING_COPYPOSTFIELDS + 1) + if((int) STRING_LAST != (int) STRING_BEARER + 1) curl_mfprintf(stderr, "*** WARNING: curl_easy_setopt_ccsid() should be reworked ***\n"); } @@ -1149,7 +1154,6 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...) case CURLOPT_NETRC_FILE: case CURLOPT_NOPROXY: case CURLOPT_PASSWORD: - case CURLOPT_PINNEDPUBLICKEY: case CURLOPT_PROXY: case CURLOPT_PROXYPASSWORD: case CURLOPT_PROXYUSERNAME: @@ -1174,7 +1178,6 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...) case CURLOPT_TLSAUTH_PASSWORD: case CURLOPT_TLSAUTH_TYPE: case CURLOPT_TLSAUTH_USERNAME: - case CURLOPT_UNIX_SOCKET_PATH: case CURLOPT_URL: case CURLOPT_USERAGENT: case CURLOPT_USERNAME: @@ -1224,7 +1227,6 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...) } else { /* Data length specified. */ - size_t len; if(pfsize < 0 || pfsize > SIZE_MAX) { result = CURLE_OUT_OF_MEMORY;