code cleanup

git-svn: trunk@1899
remotes/push_mirror/metadata
Tomasz Kojm 19 years ago
parent 114be148cf
commit 75282b5c33
  1. 5
      clamav-devel/ChangeLog
  2. 41
      clamav-devel/libclamav/chmunpack.c
  3. 2
      clamav-devel/libclamav/htmlnorm.c
  4. 1
      clamav-devel/libclamav/matcher-bm.c
  5. 1
      clamav-devel/libclamav/matcher.c
  6. 24
      clamav-devel/libclamav/msexpand.c
  7. 29
      clamav-devel/libclamav/ole2_extract.c
  8. 45
      clamav-devel/libclamav/others.h
  9. 6
      clamav-devel/libclamav/pdf.c
  10. 16
      clamav-devel/libclamav/pe.c
  11. 11
      clamav-devel/libclamav/petite.c
  12. 15
      clamav-devel/libclamav/rebuildpe.c
  13. 16
      clamav-devel/libclamav/sis.c
  14. 41
      clamav-devel/libclamav/special.c
  15. 13
      clamav-devel/libclamav/spin.c
  16. 12
      clamav-devel/libclamav/tnef.c
  17. 21
      clamav-devel/libclamav/unrar/unrar.c
  18. 43
      clamav-devel/libclamav/vba_extract.c
  19. 21
      clamav-devel/libclamav/yc.c

@ -1,3 +1,8 @@
Sat Apr 8 01:22:47 CEST 2006 (tk)
----------------------------------
* libclamav: code cleanup: move repeated endian conversion and other (MAX,
MIN, etc.) macros into others.h. Patch by Andrey J. Melnikoff
Fri Apr 7 21:09:25 CEST 2006 (tk)
----------------------------------
* libclamav: initial support for Sensory Networks' NodalCore Accelerator

@ -46,11 +46,6 @@
#include "mspack/lzx.h"
#include "cltypes.h"
#define FALSE (0)
#define TRUE (1)
#define MIN(a,b) ((a < b) ? a : b)
#ifndef HAVE_ATTRIB_PACKED
#define __attribute__(x)
#endif
@ -149,39 +144,9 @@ typedef struct lzx_content_tag {
#pragma pack()
#endif
#if WORDS_BIGENDIAN == 0
#define chm_endian_convert_16(v) (v)
#else
static uint16_t chm_endian_convert_16(uint16_t v)
{
return ((v >> 8) + (v << 8));
}
#endif
#if WORDS_BIGENDIAN == 0
#define chm_endian_convert_32(v) (v)
#else
static uint32_t chm_endian_convert_32(uint32_t v)
{
return ((v >> 24) | ((v & 0x00FF0000) >> 8) |
((v & 0x0000FF00) << 8) | (v << 24));
}
#endif
#if WORDS_BIGENDIAN == 0
#define chm_endian_convert_64(v) (v)
#else
static uint64_t chm_endian_convert_64(uint64_t v)
{
return ((v >> 56) | ((v & 0x00FF000000000000LL) >> 40) |
((v & 0x0000FF0000000000LL) >> 24) |
((v & 0x000000FF00000000LL) >> 8) |
((v & 0x00000000FF000000LL) << 8) |
((v & 0x0000000000FF0000LL) << 24) |
((v & 0x000000000000FF00LL) << 40) |
(v << 56));
}
#endif
#define chm_endian_convert_16(x) le16_to_host(x)
#define chm_endian_convert_32(x) le32_to_host(x)
#define chm_endian_convert_64(x) le64_to_host(x)
/* Read in a block of data from either the mmap area or the given fd */
int chm_read_data(int fd, unsigned char *dest, off_t offset, off_t len,

@ -47,8 +47,6 @@
#include "htmlnorm.h"
#define HTML_STR_LENGTH 1024
#define FALSE (0)
#define TRUE (1)
typedef enum {
HTML_BAD_STATE,

@ -31,7 +31,6 @@
/* #define BM_TEST_OFFSET 5 */
#define BM_BLOCK_SIZE 3
#define MIN(a,b) (a < b) ? a : b
#define HASH(a,b,c) 211 * (unsigned char) a + 37 * (unsigned char) b + (unsigned char) c
#define DHASH(a,b,c) 211 * a + 37 * b + c

@ -39,7 +39,6 @@
#include "special.h"
#define MD5_BLOCKSIZE 4096
#define MAX(a,b) ((a > b) ? a : b)
static int targettab[CL_TARGET_TABLE_SIZE] = { 0, CL_TYPE_MSEXE, CL_TYPE_MSOLE2, CL_TYPE_HTML, CL_TYPE_MAIL, CL_TYPE_GRAPHICS, CL_TYPE_ELF };

@ -45,11 +45,7 @@ int cli_msexpand(FILE *in, FILE *out)
return -1;
}
#if WORDS_BIGENDIAN == 1
if(magic1 == 0x535A4444L)
#else
if(magic1 == 0x44445A53L)
#endif
if(magic1 == le32_to_host(0x44445A53L))
{
if(fread(&magic2, sizeof(magic2), 1, in) != 1) {
return -1;
@ -63,22 +59,14 @@ int cli_msexpand(FILE *in, FILE *out)
return -1;
}
#if WORDS_BIGENDIAN == 1
if(magic2 != 0x88F02733L)
#else
if(magic2 != 0x3327F088L)
#endif
if(magic2 != le32_to_host(0x3327F088L))
{
cli_warnmsg("msexpand: Not a MS-compressed file\n");
return -1;
}
} else
#if WORDS_BIGENDIAN == 1
if(magic1 == 0x4B57414AL)
#else
if(magic1 == 0x4A41574BL)
#endif
if(magic1 == le32_to_host(0x4A41574BL))
{
if(fread(&magic2, sizeof(magic2), 1, in) != 1) {
return -1;
@ -92,11 +80,7 @@ int cli_msexpand(FILE *in, FILE *out)
return -1;
}
#if WORDS_BIGENDIAN == 1
if(magic2 != 0x88F027D1L || magic3 != 0x03001200L)
#else
if(magic2 != 0xD127F088L || magic3 != 0x00120003L)
#endif
if(magic2 != le32_to_host(0xD127F088L) || magic3 != le32_to_host(0x00120003L))
{
cli_warnmsg("msexpand: Not a MS-compressed file\n");
return -1;

@ -46,33 +46,8 @@
#include "others.h"
#include "ole2_extract.h"
#ifndef FALSE
#define FALSE (0)
#define TRUE (1)
#endif
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
#if WORDS_BIGENDIAN == 0
#define ole2_endian_convert_16(v) (v)
#else
static uint16_t ole2_endian_convert_16(uint16_t v)
{
return ((v >> 8) + (v << 8));
}
#endif
#if WORDS_BIGENDIAN == 0
#define ole2_endian_convert_32(v) (v)
#else
static uint32_t ole2_endian_convert_32(uint32_t v)
{
return ((v >> 24) | ((v & 0x00FF0000) >> 8) |
((v & 0x0000FF00) << 8) | (v << 24));
}
#endif
#define ole2_endian_convert_16(v) le16_to_host(v)
#define ole2_endian_convert_32(v) le32_to_host(v)
#ifndef HAVE_ATTRIB_PACKED
#define __attribute__(x)

@ -64,6 +64,51 @@ typedef struct {
#define BLOCKMAX (ctx->options & CL_SCAN_BLOCKMAX)
#define DETECT_BROKEN (ctx->options & CL_SCAN_BLOCKBROKEN)
#if WORDS_BIGENDIAN == 0
/* new macros from A. Melnikoff */
#define le16_to_host(v) (v)
#define le32_to_host(v) (v)
#define le64_to_host(v) (v)
#define be16_to_host(v) ((v >> 8) | (v << 8))
#define be32_to_host(v) ((v >> 24) | ((v & 0x00FF0000) >> 8) | \
((v & 0x0000FF00) << 8) | (v << 24))
#define be64_to_host(v) ((v >> 56) | ((v & 0x00FF000000000000LL) >> 40) | \
((v & 0x0000FF0000000000LL) >> 24) | \
((v & 0x000000FF00000000LL) >> 8) | \
((v & 0x00000000FF000000LL) << 8) | \
((v & 0x0000000000FF0000LL) << 24) | \
((v & 0x000000000000FF00LL) << 40) | \
(v << 56))
#else
#define le16_to_host(v) ((v >> 8) | (v << 8))
#define le32_to_host(v) ((v >> 24) | ((v & 0x00FF0000) >> 8) | \
((v & 0x0000FF00) << 8) | (v << 24))
#define le64_to_host(v) ((v >> 56) | ((v & 0x00FF000000000000LL) >> 40) | \
((v & 0x0000FF0000000000LL) >> 24) | \
((v & 0x000000FF00000000LL) >> 8) | \
((v & 0x00000000FF000000LL) << 8) | \
((v & 0x0000000000FF0000LL) << 24) | \
((v & 0x000000000000FF00LL) << 40) | \
(v << 56))
#define be16_to_host(v) (v)
#define be32_to_host(v) (v)
#define be64_to_host(v) (v)
#endif
/* used by: spin, yc (C) aCaB */
#define ROL(a,b) a = ( a << (b % (sizeof(a)<<3) )) | (a >> ( (sizeof(a)<<3) - (b % (sizeof(a)<<3 )) ) )
#define ROR(a,b) a = ( a >> (b % (sizeof(a)<<3) )) | (a << ( (sizeof(a)<<3) - (b % (sizeof(a)<<3 )) ) )
#define FALSE (0)
#define TRUE (1)
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
typedef struct bitset_tag
{
unsigned char *bitset;

@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
static char const rcsid[] = "$Id: pdf.c,v 1.45 2006/03/11 15:54:09 nigelhorne Exp $";
static char const rcsid[] = "$Id: pdf.c,v 1.46 2006/04/07 23:31:41 kojm Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -53,10 +53,6 @@ static char const rcsid[] = "$Id: pdf.c,v 1.45 2006/03/11 15:54:09 nigelhorne Ex
#include "pdf.h"
#include "md5.h"
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
static int flatedecode(const unsigned char *buf, size_t len, int fout, const cli_ctx *ctx);
static int ascii85decode(const char *buf, size_t len, unsigned char *output);
static const char *pdf_nextlinestart(const char *ptr, size_t len);

@ -55,20 +55,8 @@
#define UPX_NRV2D "\x83\xf0\xff\x74\x78\xd1\xf8\x89\xc5\xeb\x0b\x01\xdb\x75\x07\x8b\x1e\x83\xee\xfc\x11\xdb\x11\xc9"
#define UPX_NRV2E "\xeb\x52\x31\xc9\x83\xe8\x03\x72\x11\xc1\xe0\x08\x8a\x06\x46\x83\xf0\xff\x74\x75\xd1\xf8\x89\xc5"
#if WORDS_BIGENDIAN == 0
#define EC16(v) (v)
#define EC32(v) (v)
#else
static inline uint16_t EC16(uint16_t v)
{
return ((v >> 8) + (v << 8));
}
static inline uint32_t EC32(uint32_t v)
{
return ((v >> 24) | ((v & 0x00FF0000) >> 8) | ((v & 0x0000FF00) << 8) | (v << 24));
}
#endif
#define EC32(x) le32_to_host(x) /* Convert little endian to host */
#define EC16(x) le16_to_host(x)
extern short cli_leavetemps_flag;

@ -59,16 +59,7 @@
#include "rebuildpe.h"
#include "others.h"
#if WORDS_BIGENDIAN == 0
#define EC32(v) (v)
#else
static inline uint32_t EC32(uint32_t v)
{
return ((v >> 24) | ((v & 0x00FF0000) >> 8) | ((v & 0x0000FF00) << 8) | (v << 24));
}
#endif
#define MAX(a,b) ((a > b) ? a : b)
#define EC32(x) le32_to_host(x) /* Convert little endian to host */
static int doubledl(char **scur, uint8_t *mydlptr, char *buffer, uint32_t buffersize)
{

@ -45,19 +45,8 @@
#include "rebuildpe.h"
#include "others.h"
#if WORDS_BIGENDIAN == 0
#define EC32(v) (v)
#define EC16(v) (v)
#else
static inline uint32_t EC32(uint32_t v)
{
return ((v >> 24) | ((v & 0x00FF0000) >> 8) | ((v & 0x0000FF00) << 8) | (v << 24));
}
static inline uint16_t EC16(uint16_t v)
{
return ((v >> 8) + (v << 8));
}
#endif
#define EC32(x) le32_to_host(x) /* Convert little endian to host */
#define EC16(x) le16_to_host(x) /* Convert little endian to host */
struct IMAGE_PE_HEADER {
uint32_t Signature;

@ -44,20 +44,8 @@
#include "clamav.h"
#include "sis.h"
#if WORDS_BIGENDIAN == 0
#define EC16(v) (v)
#define EC32(v) (v)
#else
static inline uint16_t EC16(uint16_t v)
{
return ((v >> 8) + (v << 8));
}
static inline uint32_t EC32(uint32_t v)
{
return ((v >> 24) | ((v & 0x00FF0000) >> 8) | ((v & 0x0000FF00) << 8) | (v << 24));
}
#endif
#define EC32(x) le32_to_host(x) /* Convert little endian to host */
#define EC16(x) le16_to_host(x) /* Convert little endian to host */
extern short cli_leavetemps_flag;

@ -30,29 +30,11 @@
#include "cltypes.h"
#include "special.h"
#define FALSE (0)
#define TRUE (1)
/* NOTE: Photoshop stores data in BIG ENDIAN format, this is the opposite
to virtually everything else */
#if WORDS_BIGENDIAN == 0
static uint16_t special_endian_convert_16(uint16_t v)
{
return ((v >> 8) + (v << 8));
}
#else
#define special_endian_convert_16(v) (v)
#endif
#if WORDS_BIGENDIAN == 0
static uint32_t special_endian_convert_32(uint32_t v)
{
return ((v >> 24) | ((v & 0x00FF0000) >> 8) |
((v & 0x0000FF00) << 8) | (v << 24));
}
#else
#define special_endian_convert_32(v) (v)
#endif
#define special_endian_convert_16(v) be16_to_host(v)
#define special_endian_convert_32(v) be32_to_host(v)
int cli_check_mydoom_log(int desc, const char **virname)
{
@ -243,21 +225,10 @@ int cli_check_jpeg_exploit(int fd)
static uint32_t riff_endian_convert_32(uint32_t value, int big_endian)
{
if (big_endian) {
#if WORDS_BIGENDIAN == 0
return ((value >> 24) | ((value & 0x00FF0000) >> 8) |
((value & 0x0000FF00) << 8) | (value << 24));
#else
return value;
#endif
} else {
#if WORDS_BIGENDIAN == 0
return value;
#else
return ((value >> 24) | ((value & 0x00FF0000) >> 8) |
((value & 0x0000FF00) << 8) | (value << 24));
#endif
}
if (big_endian)
return be32_to_host(value);
else
return le32_to_host(value);
}
static int riff_read_chunk(int fd, int big_endian, int rec_level)

@ -63,18 +63,7 @@
#include "others.h"
#include "spin.h"
#if WORDS_BIGENDIAN == 0
#define EC32(v) (v)
#else
static inline uint32_t EC32(uint32_t v)
{
return ((v >> 24) | ((v & 0x00FF0000) >> 8) | ((v & 0x0000FF00) << 8) | (v << 24));
}
#endif
#define ROL(a,b) a = ( a << (b % (sizeof(a)<<3) )) | (a >> ( (sizeof(a)<<3) - (b % (sizeof(a)<<3 )) ) )
#define ROR(a,b) a = ( a >> (b % (sizeof(a)<<3) )) | (a << ( (sizeof(a)<<3) - (b % (sizeof(a)<<3 )) ) )
#define EC32(x) le32_to_host(x) /* Convert little endian to host */
static char exec86(uint8_t aelle, uint8_t cielle, char *curremu) {
int len = 0;

@ -24,7 +24,7 @@
#include "clamav-config.h"
#endif
static char const rcsid[] = "$Id: tnef.c,v 1.31 2006/03/14 11:39:43 nigelhorne Exp $";
static char const rcsid[] = "$Id: tnef.c,v 1.32 2006/04/07 23:31:41 kojm Exp $";
#include <stdio.h>
#include <fcntl.h>
@ -54,14 +54,8 @@ static int tnef_header(FILE *fp, uint8_t *part, uint16_t *type, uint16_t *tag, i
#define attTNEFVERSION 0x9006
#define attOEMCODEPAGE 0x9007
#if WORDS_BIGENDIAN == 0
#define host16(v) (v)
#define host32(v) (v)
#else
#define host16(v) ((v >> 8) | (v << 8))
#define host32(v) ((v >> 24) | ((v & 0x00FF0000) >> 8) | \
((v & 0x0000FF00) << 8) | (v << 24))
#endif
#define host16(v) le16_to_host(v)
#define host32(v) le32_to_host(v)
extern short cli_debug_flag;

@ -44,6 +44,8 @@
#include "cltypes.h"
#define int64to32(x) ((uint)(x))
#define rar_endian_convert_16(v) le16_to_host(v)
#define rar_endian_convert_32(v) le32_to_host(v)
#ifdef RAR_HIGH_DEBUG
#define rar_dbgmsg printf
@ -129,25 +131,6 @@ static void dump_tables(unpack_data_t *unpack_data)
cli_dbgmsg("\n");
}
#if WORDS_BIGENDIAN == 0
#define rar_endian_convert_16(v) (v)
#else
static uint16_t rar_endian_convert_16(uint16_t v)
{
return ((v >> 8) + (v << 8));
}
#endif
#if WORDS_BIGENDIAN == 0
#define rar_endian_convert_32(v) (v)
#else
static uint32_t rar_endian_convert_32(uint32_t v)
{
return ((v >> 24) | ((v & 0x00FF0000) >> 8) |
((v & 0x0000FF00) << 8) | (v << 24));
}
#endif
static uint64_t copy_file_data(int ifd, int ofd, uint64_t len)
{
unsigned char data[8192];

@ -39,13 +39,6 @@
#include "vba_extract.h"
#include "others.h"
#define FALSE (0)
#define TRUE (1)
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
typedef struct vba_version_tag {
unsigned char signature[4];
const char *name;
@ -56,38 +49,18 @@ typedef struct vba_version_tag {
static uint16_t vba_endian_convert_16(uint16_t value, int is_mac)
{
if (is_mac) {
#if WORDS_BIGENDIAN == 0
return ((value >> 8) + (value << 8));
#else
return value;
#endif
} else {
#if WORDS_BIGENDIAN == 0
return value;
#else
return ((value >> 8) + (value << 8));
#endif
}
if (is_mac)
return be16_to_host(value);
else
return le16_to_host(value);
}
static uint32_t vba_endian_convert_32(uint32_t value, int is_mac)
{
if (is_mac) {
#if WORDS_BIGENDIAN == 0
return ((value >> 24) | ((value & 0x00FF0000) >> 8) |
((value & 0x0000FF00) << 8) | (value << 24));
#else
return value;
#endif
} else {
#if WORDS_BIGENDIAN == 0
return value;
#else
return ((value >> 24) | ((value & 0x00FF0000) >> 8) |
((value & 0x0000FF00) << 8) | (value << 24));
#endif
}
if (is_mac)
return be32_to_host(value);
else
return le32_to_host(value);
}
typedef struct byte_array_tag {

@ -34,25 +34,8 @@
#include "pe.h"
#include "others.h"
/* Macros were created by aCaB */
#define ROL(a,b) a = ( a << (b % (sizeof(a)<<3) )) | (a >> ( (sizeof(a)<<3) - (b % (sizeof(a)<<3 )) ) )
#define ROR(a,b) a = ( a >> (b % (sizeof(a)<<3) )) | (a << ( (sizeof(a)<<3) - (b % (sizeof(a)<<3 )) ) )
#if WORDS_BIGENDIAN == 0
#define EC16(v) (v)
#define EC32(v) (v)
#else
static inline uint16_t EC16(uint16_t v)
{
return ((v >> 8) + (v << 8));
}
static inline uint32_t EC32(uint32_t v)
{
return ((v >> 24) | ((v & 0x00FF0000) >> 8) | ((v & 0x0000FF00) << 8) | (v << 24));
}
#endif
#define EC32(x) le32_to_host(x) /* Convert little endian to host */
#define EC16(x) le16_to_host(x) /* Convert little endian to host */
/* ========================================================================== */
/* "Emulates" the poly decryptors */

Loading…
Cancel
Save