... | ... |
@@ -46,6 +46,7 @@ |
46 | 46 |
#include "clamav.h" |
47 | 47 |
#include "fmap.h" |
48 | 48 |
#include "str.h" |
49 |
+#include "conv.h" |
|
49 | 50 |
#include "others.h" |
50 | 51 |
#include "scanners.h" |
51 | 52 |
#include "msxml_parser.h" |
... | ... |
@@ -79,9 +80,9 @@ |
79 | 79 |
typedef int (*hwp_cb )(void *cbdata, int fd, cli_ctx *ctx); |
80 | 80 |
static int decompress_and_callback(cli_ctx *ctx, fmap_t *input, off_t at, size_t len, const char *parent, hwp_cb cb, void *cbdata) |
81 | 81 |
{ |
82 |
- int zret, ofd, ret = CL_SUCCESS; |
|
82 |
+ int zret, ofd, in, ret = CL_SUCCESS; |
|
83 | 83 |
off_t off_in = at; |
84 |
- size_t in, count, remain = 1, outsize = 0; |
|
84 |
+ size_t count, remain = 1, outsize = 0; |
|
85 | 85 |
z_stream zstrm; |
86 | 86 |
char *tmpname; |
87 | 87 |
unsigned char inbuf[FILEBUFF], outbuf[FILEBUFF]; |
... | ... |
@@ -252,11 +253,23 @@ static char *convert_hstr_to_utf8(const char *begin, size_t sz, const char *pare |
252 | 252 |
#endif |
253 | 253 |
/* safety base64 encoding */ |
254 | 254 |
if (!res && (rc == CL_SUCCESS)) { |
255 |
- res = (char *)cl_base64_encode((const uint8_t *)begin, sz); |
|
256 |
- if (res) |
|
257 |
- rc = CL_VIRUS; /* used as placeholder */ |
|
258 |
- else |
|
255 |
+ char *tmpbuf; |
|
256 |
+ |
|
257 |
+ tmpbuf = cli_calloc(1, sz+1); |
|
258 |
+ if (tmpbuf) { |
|
259 |
+ memcpy(tmpbuf, begin, sz); |
|
260 |
+ |
|
261 |
+ res = (char *)cl_base64_encode(tmpbuf, sz); |
|
262 |
+ if (res) |
|
263 |
+ rc = CL_VIRUS; /* used as placeholder */ |
|
264 |
+ else |
|
265 |
+ rc = CL_EMEM; |
|
266 |
+ |
|
267 |
+ free(tmpbuf); |
|
268 |
+ } else { |
|
269 |
+ cli_errmsg("%s: Failed to allocate memory for temporary buffer\n", parent); |
|
259 | 270 |
rc = CL_EMEM; |
271 |
+ } |
|
260 | 272 |
} |
261 | 273 |
|
262 | 274 |
(*ret) = rc; |
... | ... |
@@ -1975,7 +1988,7 @@ static int hwpml_binary_cb(int fd, cli_ctx *ctx, int num_attribs, struct attrib_ |
1975 | 1975 |
return CL_EMAP; |
1976 | 1976 |
} |
1977 | 1977 |
|
1978 |
- decoded = (char *)cl_base64_decode(instream, input->len, NULL, &decodedlen, 0); |
|
1978 |
+ decoded = (char *)cl_base64_decode((char *)instream, input->len, NULL, &decodedlen, 0); |
|
1979 | 1979 |
funmap(input); |
1980 | 1980 |
if (!decoded) { |
1981 | 1981 |
cli_errmsg("HWPML: Failed to get base64 decode binary data\n"); |
... | ... |
@@ -309,8 +309,8 @@ static int msxml_parse_element(struct msxml_ctx *mxctx, xmlTextReaderPtr reader, |
309 | 309 |
state = xmlTextReaderMoveToFirstAttribute(reader); |
310 | 310 |
if (state == 1) { |
311 | 311 |
/* read first attribute (current head) */ |
312 |
- attribs[num_attribs].key = xmlTextReaderConstLocalName(reader); |
|
313 |
- attribs[num_attribs].value = xmlTextReaderConstValue(reader); |
|
312 |
+ attribs[num_attribs].key = (const char *)xmlTextReaderConstLocalName(reader); |
|
313 |
+ attribs[num_attribs].value = (const char *)xmlTextReaderConstValue(reader); |
|
314 | 314 |
num_attribs++; |
315 | 315 |
} else if (state == -1) { |
316 | 316 |
return CL_EPARSE; |
... | ... |
@@ -322,8 +322,8 @@ static int msxml_parse_element(struct msxml_ctx *mxctx, xmlTextReaderPtr reader, |
322 | 322 |
cli_msxmlmsg("msxml_parse_element: adding attributes to scanning context\n"); |
323 | 323 |
|
324 | 324 |
while ((num_attribs < MAX_ATTRIBS) && (xmlTextReaderMoveToNextAttribute(reader) == 1)) { |
325 |
- attribs[num_attribs].key = xmlTextReaderConstLocalName(reader); |
|
326 |
- attribs[num_attribs].value = xmlTextReaderConstValue(reader); |
|
325 |
+ attribs[num_attribs].key = (const char *)xmlTextReaderConstLocalName(reader); |
|
326 |
+ attribs[num_attribs].value = (const char *)xmlTextReaderConstValue(reader); |
|
327 | 327 |
num_attribs++; |
328 | 328 |
} |
329 | 329 |
} |