View | Details | Raw Unified
Collapse All | Expand All

(-) clamav-0.91.2/libclamav/pe.c (-10 / +15 lines)
 Lines 80-85    Link Here 
#define PEALIGN(o,a) (((a))?(((o)/(a))*(a)):(o))
#define PEALIGN(o,a) (((a))?(((o)/(a))*(a)):(o))
#define PESALIGN(o,a) (((a))?(((o)/(a)+((o)%(a)!=0))*(a)):(o))
#define PESALIGN(o,a) (((a))?(((o)/(a)+((o)%(a)!=0))*(a)):(o))
#define CLI_UNPSIZELIMITS(NAME,CHK) \
if(ctx->limits && ctx->limits->maxfilesize && (CHK) > ctx->limits->maxfilesize) { \
    cli_dbgmsg(NAME": Sizes exceeded (%lu > %lu)\n", (CHK), ctx->limits->maxfilesize); \
    free(exe_sections); \
    if(BLOCKMAX) { \
        *ctx->virname = "PE."NAME".ExceededFileSize"; \
        return CL_VIRUS; \
    } else { \
        return CL_CLEAN; \
    } \
}
extern short cli_leavetemps_flag;
extern short cli_leavetemps_flag;
struct offset_list {
struct offset_list {
 Lines 1153-1168   int cli_scanpe(int desc, cli_ctx *ctx) Link Here 
		dsize = exe_sections[i].vsz;
		dsize = exe_sections[i].vsz;
		cli_dbgmsg("MEW: ssize %08x dsize %08x offdiff: %08x\n", ssize, dsize, offdiff);
		cli_dbgmsg("MEW: ssize %08x dsize %08x offdiff: %08x\n", ssize, dsize, offdiff);
		if(ctx->limits && ctx->limits->maxfilesize && (ssize + dsize > ctx->limits->maxfilesize || exe_sections[i + 1].rsz > ctx->limits->maxfilesize)) {
		    cli_dbgmsg("MEW: Sizes exceeded (ssize: %u, dsize: %u, max: %lu)\n", ssize, dsize , ctx->limits->maxfilesize);
		CLI_UNPSIZELIMITS("MEW", MAX(ssize, dsize));
		    free(exe_sections);
		CLI_UNPSIZELIMITS("MEW", MAX(ssize + dsize, exe_sections[i + 1].rsz));
		    if(BLOCKMAX) {
			*ctx->virname = "PE.MEW.ExceededFileSize";
			return CL_VIRUS;
		    } else {
			return CL_CLEAN;
		    }
		}
		/* allocate needed buffer */
		/* allocate needed buffer */
		if (!(src = cli_calloc (ssize + dsize, sizeof(char)))) {
		if (!(src = cli_calloc (ssize + dsize, sizeof(char)))) {