[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 120/256: non-ascii: allow conversion functions to b
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 120/256: non-ascii: allow conversion functions to be called with a NULL data handle. |
Date: |
Fri, 06 Oct 2017 19:43:31 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 70231d6a6551ab89ea2801df661fc1cd17967ba7
Author: Patrick Monnerat <address@hidden>
AuthorDate: Sat Sep 2 12:45:21 2017 +0100
non-ascii: allow conversion functions to be called with a NULL data handle.
---
lib/non-ascii.c | 56 +++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 37 insertions(+), 19 deletions(-)
diff --git a/lib/non-ascii.c b/lib/non-ascii.c
index ae0097036..0a768bd91 100644
--- a/lib/non-ascii.c
+++ b/lib/non-ascii.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <address@hidden>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <address@hidden>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -82,7 +82,7 @@ CURLcode Curl_convert_clone(struct Curl_easy *data,
CURLcode Curl_convert_to_network(struct Curl_easy *data,
char *buffer, size_t length)
{
- if(data->set.convtonetwork) {
+ if(data && data->set.convtonetwork) {
/* use translation callback */
CURLcode result = data->set.convtonetwork(buffer, length);
if(result) {
@@ -96,14 +96,18 @@ CURLcode Curl_convert_to_network(struct Curl_easy *data,
else {
#ifdef HAVE_ICONV
/* do the translation ourselves */
+ iconv_t tmpcd = (iconv_t) -1;
+ iconv_t *cd = &tmpcd;
char *input_ptr, *output_ptr;
size_t in_bytes, out_bytes, rc;
/* open an iconv conversion descriptor if necessary */
- if(data->outbound_cd == (iconv_t)-1) {
- data->outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
- CURL_ICONV_CODESET_OF_HOST);
- if(data->outbound_cd == (iconv_t)-1) {
+ if(data)
+ cd = &data->outbound_cd;
+ if(*cd == (iconv_t)-1) {
+ *cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
+ CURL_ICONV_CODESET_OF_HOST);
+ if(*cd == (iconv_t)-1) {
failf(data,
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
CURL_ICONV_CODESET_OF_NETWORK,
@@ -115,8 +119,10 @@ CURLcode Curl_convert_to_network(struct Curl_easy *data,
/* call iconv */
input_ptr = output_ptr = buffer;
in_bytes = out_bytes = length;
- rc = iconv(data->outbound_cd, (const char **)&input_ptr, &in_bytes,
+ rc = iconv(*cd, (const char **)&input_ptr, &in_bytes,
&output_ptr, &out_bytes);
+ if(!data)
+ iconv_close(tmpcd);
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
failf(data,
"The Curl_convert_to_network iconv call failed with errno %i: %s",
@@ -139,7 +145,7 @@ CURLcode Curl_convert_to_network(struct Curl_easy *data,
CURLcode Curl_convert_from_network(struct Curl_easy *data,
char *buffer, size_t length)
{
- if(data->set.convfromnetwork) {
+ if(data && data->set.convfromnetwork) {
/* use translation callback */
CURLcode result = data->set.convfromnetwork(buffer, length);
if(result) {
@@ -153,14 +159,18 @@ CURLcode Curl_convert_from_network(struct Curl_easy *data,
else {
#ifdef HAVE_ICONV
/* do the translation ourselves */
+ iconv_t tmpcd = (iconv_t) -1;
+ iconv_t *cd = &tmpcd;
char *input_ptr, *output_ptr;
size_t in_bytes, out_bytes, rc;
/* open an iconv conversion descriptor if necessary */
- if(data->inbound_cd == (iconv_t)-1) {
- data->inbound_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
- CURL_ICONV_CODESET_OF_NETWORK);
- if(data->inbound_cd == (iconv_t)-1) {
+ if(data)
+ cd = &data->inbound_cd;
+ if(*cd == (iconv_t)-1) {
+ *cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
+ CURL_ICONV_CODESET_OF_NETWORK);
+ if(*cd == (iconv_t)-1) {
failf(data,
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
CURL_ICONV_CODESET_OF_HOST,
@@ -172,8 +182,10 @@ CURLcode Curl_convert_from_network(struct Curl_easy *data,
/* call iconv */
input_ptr = output_ptr = buffer;
in_bytes = out_bytes = length;
- rc = iconv(data->inbound_cd, (const char **)&input_ptr, &in_bytes,
+ rc = iconv(*cd, (const char **)&input_ptr, &in_bytes,
&output_ptr, &out_bytes);
+ if(!data)
+ iconv_close(tmpcd);
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
failf(data,
"Curl_convert_from_network iconv call failed with errno %i: %s",
@@ -196,7 +208,7 @@ CURLcode Curl_convert_from_network(struct Curl_easy *data,
CURLcode Curl_convert_from_utf8(struct Curl_easy *data,
char *buffer, size_t length)
{
- if(data->set.convfromutf8) {
+ if(data && data->set.convfromutf8) {
/* use translation callback */
CURLcode result = data->set.convfromutf8(buffer, length);
if(result) {
@@ -210,15 +222,19 @@ CURLcode Curl_convert_from_utf8(struct Curl_easy *data,
else {
#ifdef HAVE_ICONV
/* do the translation ourselves */
+ iconv_t tmpcd = (iconv_t) -1;
+ iconv_t *cd = &tmpcd;
const char *input_ptr;
char *output_ptr;
size_t in_bytes, out_bytes, rc;
/* open an iconv conversion descriptor if necessary */
- if(data->utf8_cd == (iconv_t)-1) {
- data->utf8_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
- CURL_ICONV_CODESET_FOR_UTF8);
- if(data->utf8_cd == (iconv_t)-1) {
+ if(data)
+ cd = &data->utf8_cd;
+ if(*cd == (iconv_t)-1) {
+ *cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
+ CURL_ICONV_CODESET_FOR_UTF8);
+ if(*cd == (iconv_t)-1) {
failf(data,
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
CURL_ICONV_CODESET_OF_HOST,
@@ -230,8 +246,10 @@ CURLcode Curl_convert_from_utf8(struct Curl_easy *data,
/* call iconv */
input_ptr = output_ptr = buffer;
in_bytes = out_bytes = length;
- rc = iconv(data->utf8_cd, &input_ptr, &in_bytes,
+ rc = iconv(*cd, &input_ptr, &in_bytes,
&output_ptr, &out_bytes);
+ if(!data)
+ iconv_close(tmpcd);
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
failf(data,
"The Curl_convert_from_utf8 iconv call failed with errno %i: %s",
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 163/256: mime: drop internal FILE * support., (continued)
- [GNUnet-SVN] [gnurl] 163/256: mime: drop internal FILE * support., gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 145/256: curl.h: fix "unused checksrc ignore", remove dangling reference, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 159/256: mime: fix a trivial warning., gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 220/256: tests: make the imap server not verify user+password, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 210/256: cookies: use lock when using CURLINFO_COOKIELIST, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 208/256: mime:escape_string minor clarification change, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 160/256: openssl: Integrate Peter Wu's SSLKEYLOGFILE implementation, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 177/256: configure: use -Wno-varargs on clang 3.9[.X] debug builds, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 172/256: KNOWN_BUGS: Remove CMake symbol hiding issue, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 213/256: curl: check fseek() return code and bail on error, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 120/256: non-ascii: allow conversion functions to be called with a NULL data handle.,
gnunet <=
- [GNUnet-SVN] [gnurl] 244/256: libcurl-tutorial: fix two typos., gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 205/256: travis: on mac, don't install openssl or libidn, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 247/256: test1153: verify quoted double-qoutes in PWD response, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 228/256: ntlm: move NTLM_NEEDS_NSS_INIT define into core NTLM header, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 142/256: schannel: return CURLE_SSL_CACERT on failed verification, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 122/256: runtests.pl: Apply strippart to upload too., gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 180/256: travis: add build without HTTP/SMTP/IMAP, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 113/256: unit1301: fix error message on first test, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 214/256: mime: fix an explicit null dereference (#1899), gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 194/256: tests: enable gssapi in travis-ci linux build, gnunet, 2017/10/06