[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:18:26 UTC 2010


The following commit has been merged in the debian/unstable branch:
commit f6e8bb802a671332f3d712c232436c3923da85a5
Author: Török Edvin <edwin at clamav.net>
Date:   Tue Feb 2 13:42:33 2010 +0200

    fix segfault on failed cbc load.
    
    The bytecode struct might be only partially initialized. Account for that.

diff --git a/libclamav/bytecode.c b/libclamav/bytecode.c
index 6b9b9b5..d6fcb3b 100644
--- a/libclamav/bytecode.c
+++ b/libclamav/bytecode.c
@@ -1407,43 +1407,54 @@ void cli_bytecode_destroy(struct cli_bc *bc)
     free(bc->metadata.compiler);
     free(bc->metadata.sigmaker);
 
-    for (i=0;i<bc->num_func;i++) {
-	struct cli_bc_func *f = &bc->funcs[i];
-	free(f->types);
-
-	for (j=0;j<f->numBB;j++) {
-	    struct cli_bc_bb *BB = &f->BB[j];
-	    for(k=0;k<BB->numInsts;k++) {
-		struct cli_bc_inst *ii = &BB->insts[k];
-		if (operand_counts[ii->opcode] > 3 ||
-		    ii->opcode == OP_BC_CALL_DIRECT || ii->opcode == OP_BC_CALL_API) {
-		    free(ii->u.ops.ops);
-		    free(ii->u.ops.opsizes);
+    if (bc->funcs) {
+	for (i=0;i<bc->num_func;i++) {
+	    struct cli_bc_func *f = &bc->funcs[i];
+	    if (!f)
+		continue;
+	    free(f->types);
+
+	    for (j=0;j<f->numBB;j++) {
+		struct cli_bc_bb *BB = &f->BB[j];
+		for(k=0;k<BB->numInsts;k++) {
+		    struct cli_bc_inst *ii = &BB->insts[k];
+		    if (operand_counts[ii->opcode] > 3 ||
+			ii->opcode == OP_BC_CALL_DIRECT || ii->opcode == OP_BC_CALL_API) {
+			free(ii->u.ops.ops);
+			free(ii->u.ops.opsizes);
+		    }
 		}
 	    }
+	    free(f->BB);
+	    free(f->allinsts);
+	    free(f->constants);
+	}
+	free(bc->funcs);
+    }
+    if (bc->types) {
+	for (i=NUM_STATIC_TYPES;i<bc->num_types;i++) {
+	    if (bc->types[i].containedTypes)
+		free(bc->types[i].containedTypes);
 	}
-	free(f->BB);
-	free(f->allinsts);
-	free(f->constants);
-    }
-    free(bc->funcs);
-    for (i=NUM_STATIC_TYPES;i<bc->num_types;i++) {
-	if (bc->types[i].containedTypes)
-	    free(bc->types[i].containedTypes);
-    }
-    free(bc->types);
-    for (i=0;i<bc->num_globals;i++) {
-	free(bc->globals[i]);
-    }
-    for (i=0;i<bc->dbgnode_cnt;i++) {
-	for (j=0;j<bc->dbgnodes[i].numelements;j++) {
-	    struct cli_bc_dbgnode_element *el =  &bc->dbgnodes[i].elements[j];
-	    if (el && el->string)
-		free(el->string);
+	free(bc->types);
+    }
+
+    if (bc->globals) {
+	for (i=0;i<bc->num_globals;i++) {
+	    free(bc->globals[i]);
+	}
+	free(bc->globals);
+    }
+    if (bc->dbgnodes) {
+	for (i=0;i<bc->dbgnode_cnt;i++) {
+	    for (j=0;j<bc->dbgnodes[i].numelements;j++) {
+		struct cli_bc_dbgnode_element *el =  &bc->dbgnodes[i].elements[j];
+		if (el && el->string)
+		    free(el->string);
+	    }
 	}
+	free(bc->dbgnodes);
     }
-    free(bc->dbgnodes);
-    free(bc->globals);
     free(bc->globaltys);
     if (bc->uses_apis)
 	cli_bitset_free(bc->uses_apis);

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list