diff options
-rw-r--r-- | src/common/convert.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/common/convert.c b/src/common/convert.c index c0edf21..2be2108 100644 --- a/src/common/convert.c +++ b/src/common/convert.c | |||
@@ -36,8 +36,8 @@ | |||
36 | * string is returned. | 36 | * string is returned. |
37 | */ | 37 | */ |
38 | char * | 38 | char * |
39 | EXTRACTOR_common_convert_to_utf8 (const char *input, | 39 | EXTRACTOR_common_convert_to_utf8 (const char *input, |
40 | size_t len, | 40 | size_t len, |
41 | const char *charset) | 41 | const char *charset) |
42 | { | 42 | { |
43 | #if HAVE_ICONV | 43 | #if HAVE_ICONV |
@@ -52,7 +52,7 @@ EXTRACTOR_common_convert_to_utf8 (const char *input, | |||
52 | i = input; | 52 | i = input; |
53 | cd = iconv_open ("UTF-8", charset); | 53 | cd = iconv_open ("UTF-8", charset); |
54 | if (cd == (iconv_t) - 1) | 54 | if (cd == (iconv_t) - 1) |
55 | return strdup (i); | 55 | return strndup (i, len); |
56 | if (len > 1024 * 1024) | 56 | if (len > 1024 * 1024) |
57 | { | 57 | { |
58 | iconv_close (cd); | 58 | iconv_close (cd); |
@@ -67,11 +67,11 @@ EXTRACTOR_common_convert_to_utf8 (const char *input, | |||
67 | } | 67 | } |
68 | itmp = tmp; | 68 | itmp = tmp; |
69 | finSize = tmpSize; | 69 | finSize = tmpSize; |
70 | if (iconv (cd, (char **) &input, &len, &itmp, &finSize) == SIZE_MAX) | 70 | if (iconv (cd, (char **) &input, &len, &itmp, &finSize) == ((size_t) -1)) |
71 | { | 71 | { |
72 | iconv_close (cd); | 72 | iconv_close (cd); |
73 | free (tmp); | 73 | free (tmp); |
74 | return strdup (i); | 74 | return strndup (i, len); |
75 | } | 75 | } |
76 | ret = malloc (tmpSize - finSize + 1); | 76 | ret = malloc (tmpSize - finSize + 1); |
77 | if (ret == NULL) | 77 | if (ret == NULL) |