From c1fdde8a1456311fbf23cb853a716b596b4819f3 Mon Sep 17 00:00:00 2001 From: Nigel Horne Date: Thu, 31 Aug 2006 13:50:25 +0000 Subject: [PATCH] Added Windows support git-svn: trunk@2225 --- clamav-devel/ChangeLog | 4 ++++ clamav-devel/libclamav/pe.c | 24 ++++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/clamav-devel/ChangeLog b/clamav-devel/ChangeLog index cf96ac592..66e3aa8bd 100644 --- a/clamav-devel/ChangeLog +++ b/clamav-devel/ChangeLog @@ -1,3 +1,7 @@ +Thu Aug 31 14:49:42 BST 2006 (njh) +---------------------------------- + * libclamav/pe.c: Added Windows support (with permission from ACAB) + Thu Aug 31 00:37:10 CEST 2006 (tk) ---------------------------------- * freshclam: minor code cleanup diff --git a/clamav-devel/libclamav/pe.c b/clamav-devel/libclamav/pe.c index 76488f526..2a5a6d6e5 100644 --- a/clamav-devel/libclamav/pe.c +++ b/clamav-devel/libclamav/pe.c @@ -50,6 +50,10 @@ #include "str.h" #include "execs.h" +#ifndef O_BINARY +#define O_BINARY 0 +#endif + #define IMAGE_DOS_SIGNATURE 0x5a4d /* MZ */ #define IMAGE_DOS_SIGNATURE_OLD 0x4d5a /* ZM */ #define IMAGE_NT_SIGNATURE 0x00004550 @@ -135,7 +139,7 @@ static int cli_ddump(int desc, int offset, int size, const char *file) return -1; } - if((ndesc = open(file, O_WRONLY|O_CREAT|O_TRUNC, S_IRWXU)) < 0) { + if((ndesc = open(file, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { cli_dbgmsg("Can't create file %s\n", file); lseek(desc, pos, SEEK_SET); return -1; @@ -848,7 +852,7 @@ int cli_scanpe(int desc, cli_ctx *ctx) return CL_EMEM; } - if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC, S_IRWXU)) < 0) { + if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { cli_dbgmsg("sue: Can't create file %s\n", tempfile); free(tempfile); free(sue); @@ -1020,7 +1024,7 @@ int cli_scanpe(int desc, cli_ctx *ctx) return CL_EMEM; } - if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC, S_IRWXU)) < 0) { + if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { cli_dbgmsg("FSG: Can't create file %s\n", tempfile); free(tempfile); free(section_hdr); @@ -1225,7 +1229,7 @@ int cli_scanpe(int desc, cli_ctx *ctx) return CL_EMEM; } - if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC, S_IRWXU)) < 0) { + if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { cli_dbgmsg("FSG: Can't create file %s\n", tempfile); free(tempfile); free(section_hdr); @@ -1435,7 +1439,7 @@ int cli_scanpe(int desc, cli_ctx *ctx) return CL_EMEM; } - if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC, S_IRWXU)) < 0) { + if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { cli_dbgmsg("FSG: Can't create file %s\n", tempfile); free(tempfile); free(section_hdr); @@ -1655,7 +1659,7 @@ int cli_scanpe(int desc, cli_ctx *ctx) return CL_EMEM; } - if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC, S_IRWXU)) < 0) { + if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { cli_dbgmsg("UPX/FSG: Can't create file %s\n", tempfile); free(tempfile); free(dest); @@ -1755,7 +1759,7 @@ int cli_scanpe(int desc, cli_ctx *ctx) return CL_EMEM; } - if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC, S_IRWXU)) < 0) { + if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { cli_dbgmsg("Petite: Can't create file %s\n", tempfile); free(tempfile); free(section_hdr); @@ -1837,7 +1841,7 @@ int cli_scanpe(int desc, cli_ctx *ctx) return CL_EMEM; } - if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC, S_IRWXU)) < 0) { + if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { cli_dbgmsg("PESpin: Can't create file %s\n", tempfile); free(tempfile); free(spinned); @@ -1906,7 +1910,7 @@ int cli_scanpe(int desc, cli_ctx *ctx) return CL_EMEM; } - if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC, S_IRWXU)) < 0) { + if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { cli_dbgmsg("yC: Can't create file %s\n", tempfile); free(tempfile); free(spinned); @@ -2031,7 +2035,7 @@ int cli_scanpe(int desc, cli_ctx *ctx) return CL_EMEM; } - if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC, S_IRWXU)) < 0) { + if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { cli_dbgmsg("WWPack: Can't create file %s\n", tempfile); free(tempfile); free(dest);