Fix a couple bugs and add the ability to note which objects contain Javascript

pull/6/head
Shawn Webb 11 years ago
parent c3649f0cc2
commit cd1d52d184
  1. 2
      libclamav/json_api.c
  2. 23
      libclamav/pdf.c

@ -237,7 +237,7 @@ int cli_jsonint_array(json_object *obj, int32_t val)
if (!(obj))
return CL_ENULLARG;
if (json_object_get_array(newobj) == NULL)
if (json_object_get_array(obj) == NULL)
return CL_ENULLARG;
newobj = json_object_new_int(val);

@ -2845,7 +2845,7 @@ static char *pdf_convert_utf(char *begin, size_t sz)
memcpy(buf, begin, sz);
p1 = buf;
p2 = outbuf = cli_calloc(1, sz);
p2 = outbuf = cli_calloc(1, sz+1);
if (!(outbuf)) {
free(buf);
return NULL;
@ -2991,6 +2991,7 @@ static char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const
if (fd == -1) {
cli_unlink(newobj->path);
free(newobj->path);
newobj->path = NULL;
return NULL;
}
@ -3107,11 +3108,12 @@ static char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const
if (likelyutf == 0 && len) {
/* We're not UTF-*, so just make a copy of the string and return that */
res = cli_calloc(1, len);
res = cli_calloc(1, len+1);
if (!(res))
return NULL;
memcpy(res, p1, len);
res[len] = '\0';
return res;
}
@ -3253,10 +3255,27 @@ static void Sig_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_actio
static void JavaScript_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_action *act)
{
#if HAVE_JSON
struct json_object *pdfobj, *jbig2arr, *jbig2obj;
if (!(pdf))
return;
if (!(pdf->ctx->wrkproperty))
return;
pdfobj = cli_jsonobj(pdf->ctx->wrkproperty, "PDFStats");
if (!(pdfobj))
return;
jbig2arr = cli_jsonarray(pdfobj, "JavascriptObjects");
if (!(jbig2arr))
return;
cli_jsonint_array(jbig2arr, obj->id>>8);
pdf->stats.njs++;
#endif
}
static void OpenAction_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf_action *act)

Loading…
Cancel
Save