[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b

Török Edvin edwin at clamav.net
Sun Apr 4 01:23:29 UTC 2010


The following commit has been merged in the debian/unstable branch:
commit f6471bc9d674613c316a0c95992aab82a45ca61b
Author: Török Edvin <edwin at clamav.net>
Date:   Fri Mar 19 22:20:55 2010 +0200

    More APIs.

diff --git a/libclamav/bytecode.c b/libclamav/bytecode.c
index 51629de..136161f 100644
--- a/libclamav/bytecode.c
+++ b/libclamav/bytecode.c
@@ -768,6 +768,7 @@ static void readConstant(struct cli_bc *bc, unsigned i, unsigned comp,
     }
     if (*ok && j != comp) {
 	cli_errmsg("bytecode: constant has too few subcomponents: %u < %u\n", j, comp);
+//	*ok = 0;
     }
     (*offset)++;
 }
diff --git a/libclamav/bytecode_api.c b/libclamav/bytecode_api.c
index 9a0a1e4..34e9d3c 100644
--- a/libclamav/bytecode_api.c
+++ b/libclamav/bytecode_api.c
@@ -414,7 +414,7 @@ int32_t cli_bcapi_extract_new(struct cli_bc_ctx *ctx, int32_t id)
 	(ftruncate(ctx->outfd, 0) == -1)) {
 
 	close(ctx->outfd);
-	if (!(cctx && cctx->engine->keeptmp))
+	if (!(cctx && cctx->engine->keeptmp) && ctx->tempfile)
 	    cli_unlink(ctx->tempfile);
 	free(ctx->tempfile);
 	ctx->tempfile = NULL;
@@ -423,3 +423,31 @@ int32_t cli_bcapi_extract_new(struct cli_bc_ctx *ctx, int32_t id)
     cli_dbgmsg("bytecode: extracting new file with id %u\n", id);
     return res;
 }
+
+#define BUF 16
+int32_t cli_bcapi_read_number(struct cli_bc_ctx *ctx, uint32_t radix)
+{
+    unsigned char number[16];
+    unsigned i;
+    unsigned char *p;
+    int32_t result;
+
+    if (radix != 10 && radix != 16 || !ctx->fmap)
+	return -1;
+    while ((p = fmap_need_off_once(ctx->fmap, ctx->off, BUF))) {
+	for (i=0;i<BUF;i++) {
+	    if (p[i] >= '0' && p[i] <= '9') {
+		unsigned char *endptr;
+		p = fmap_need_ptr_once(ctx->fmap, p+i, 16);
+		if (!p)
+		    return -1;
+		result = strtoul(p, &endptr, radix);
+		ctx->off += i + (endptr - p);
+		return result;
+	    }
+	}
+	ctx->off += BUF;
+    }
+    return -1;
+}
+
diff --git a/libclamav/bytecode_api.h b/libclamav/bytecode_api.h
index 2ddf2a6..6aa31fb 100644
--- a/libclamav/bytecode_api.h
+++ b/libclamav/bytecode_api.h
@@ -216,5 +216,13 @@ int32_t fill_buffer(uint8_t* buffer, uint32_t len, uint32_t filled, uint32_t cur
 */
 int32_t extract_new(int32_t id);
 
+/**
+  * Reads a number in the specified radix starting from the current position.
+  * Non-numeric characters are ignored.
+  * @param[in] radix 10 or 16
+  * @return the number read
+  */
+int32_t read_number(uint32_t radix);
+
 #endif
 #endif
diff --git a/libclamav/bytecode_api_decl.c b/libclamav/bytecode_api_decl.c
index b51d010..4e9dd77 100644
--- a/libclamav/bytecode_api_decl.c
+++ b/libclamav/bytecode_api_decl.c
@@ -55,6 +55,7 @@ uint32_t cli_bcapi_test2(struct cli_bc_ctx *ctx, uint32_t);
 int32_t cli_bcapi_get_pe_section(struct cli_bc_ctx *ctx, struct cli_exe_section*, uint32_t);
 int32_t cli_bcapi_fill_buffer(struct cli_bc_ctx *ctx, uint8_t*, uint32_t, uint32_t, uint32_t, uint32_t);
 int32_t cli_bcapi_extract_new(struct cli_bc_ctx *ctx, int32_t);
+int32_t cli_bcapi_read_number(struct cli_bc_ctx *ctx, uint32_t);
 
 const struct cli_apiglobal cli_globals[] = {
 /* Bytecode globals BEGIN */
@@ -141,7 +142,8 @@ const struct cli_apicall cli_apicalls[]={
 	{"test2", 8, 3, 2},
 	{"get_pe_section", 10, 12, 1},
 	{"fill_buffer", 9, 0, 4},
-	{"extract_new", 8, 4, 2}
+	{"extract_new", 8, 4, 2},
+	{"read_number", 8, 5, 2}
 /* Bytecode APIcalls END */
 };
 const cli_apicall_int2 cli_apicalls0[] = {
@@ -168,7 +170,8 @@ const cli_apicall_int1 cli_apicalls2[] = {
 	(cli_apicall_int1)cli_bcapi_pe_rawaddr,
 	(cli_apicall_int1)cli_bcapi_file_byteat,
 	(cli_apicall_int1)cli_bcapi_test2,
-	(cli_apicall_int1)cli_bcapi_extract_new
+	(cli_apicall_int1)cli_bcapi_extract_new,
+	(cli_apicall_int1)cli_bcapi_read_number
 };
 const cli_apicall_malloclike cli_apicalls3[] = {
 	(cli_apicall_malloclike)cli_bcapi_malloc
diff --git a/libclamav/bytecode_api_impl.h b/libclamav/bytecode_api_impl.h
index 7773ed7..262d4ba 100644
--- a/libclamav/bytecode_api_impl.h
+++ b/libclamav/bytecode_api_impl.h
@@ -52,5 +52,6 @@ uint32_t cli_bcapi_test2(struct cli_bc_ctx *ctx, uint32_t);
 int32_t cli_bcapi_get_pe_section(struct cli_bc_ctx *ctx, struct cli_exe_section*, uint32_t);
 int32_t cli_bcapi_fill_buffer(struct cli_bc_ctx *ctx, uint8_t*, uint32_t, uint32_t, uint32_t, uint32_t);
 int32_t cli_bcapi_extract_new(struct cli_bc_ctx *ctx, int32_t);
+int32_t cli_bcapi_read_number(struct cli_bc_ctx *ctx, uint32_t);
 
 #endif
diff --git a/libclamav/pe.c b/libclamav/pe.c
index 842edd9..323f408 100644
--- a/libclamav/pe.c
+++ b/libclamav/pe.c
@@ -2258,7 +2258,7 @@ int cli_scanpe(cli_ctx *ctx, icon_groupset *iconset)
 	case CL_SUCCESS:
 	    ndesc = cli_bytecode_context_getresult_file(bc_ctx, &tempfile);
 	    cli_bytecode_context_destroy(bc_ctx);
-	    if (ndesc != -1) {
+	    if (ndesc != -1 && tempfile) {
 		CLI_UNPRESULTS("bytecode PE hook", 1, 1, (0));
 	    }
 	    break;

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list