Update to align with current RAR version.

git-svn: trunk@2293
remotes/push_mirror/metadata
Trog 19 years ago
parent 8386c7239f
commit 15adc9b73a
  1. 5
      clamav-devel/ChangeLog
  2. 21
      clamav-devel/libclamav/unrar/unrar.c
  3. 51
      clamav-devel/libclamav/unrar/unrar.h
  4. 23
      clamav-devel/libclamav/unrar/unrarppm.c
  5. 4
      clamav-devel/libclamav/unrar/unrarvm.c

@ -1,3 +1,8 @@
Wed Sep 20 11:26:11 BST 2006 (trog)
-----------------------------------
*libclamav/unrar/unrar.c, unrar.h, unrarppm.c, unrarvm.c: Update to align
with current RAR version.
Wed Sep 20 11:22:56 BST 2006 (njh)
----------------------------------
* libclamav: Removed some multiple calls to blobClose() and added one

@ -1,7 +1,7 @@
/*
* Extract RAR archives
*
* Copyright (C) 2005 trog@uncon.org
* Copyright (C) 2005-2006 trog@uncon.org
*
* This code is based on the work of Alexander L. Roshal
*
@ -237,6 +237,8 @@ static void copy_string(unpack_data_t *unpack_data, unsigned int length, unsigne
static void *read_header(int fd, header_type hdr_type)
{
uint8_t encrypt_ver;
switch(hdr_type) {
case MAIN_HEAD: {
main_header_t *main_hdr;
@ -252,6 +254,14 @@ static void *read_header(int fd, header_type hdr_type)
main_hdr->flags = rar_endian_convert_16(main_hdr->flags);
main_hdr->head_size = rar_endian_convert_16(main_hdr->head_size);
main_hdr->head_crc = rar_endian_convert_16(main_hdr->head_crc);
if (main_hdr->flags & MHD_ENCRYPTVER) {
cli_dbgmsg("RAR Encrypt version: %d\n", encrypt_ver);
if (cli_readn(fd, &encrypt_ver, sizeof(uint8_t)) != sizeof(uint8_t)) {
free(main_hdr);
return NULL;
}
}
return main_hdr;
}
case FILE_HEAD: {
@ -504,7 +514,8 @@ static void unp_write_buf(unpack_data_t *unpack_data)
next_filter = unpack_data->PrgStack.array[i+1];
if (next_filter==NULL ||
next_filter->block_start!=block_start ||
next_filter->block_length!=filtered_size) {
next_filter->block_length!=filtered_size ||
next_filter->next_window) {
break;
}
rarvm_set_memory(&unpack_data->rarvm_data, 0,
@ -1355,7 +1366,7 @@ rar_metadata_t *cli_unrar(int fd, const char *dirname, const struct cl_limits *l
unsigned char filename[1024];
unpack_data_t *unpack_data;
rar_metadata_t *metadata=NULL, *metadata_tail=NULL, *new_metadata;
cli_dbgmsg("in cli_unrar\n");
if (!is_rar_archive(fd)) {
return FALSE;
@ -1370,7 +1381,7 @@ rar_metadata_t *cli_unrar(int fd, const char *dirname, const struct cl_limits *l
unpack_data->PrgStack.array = unpack_data->Filters.array = NULL;
unpack_data->PrgStack.num_items = unpack_data->Filters.num_items = 0;
unpack_data->unp_crc = 0xffffffff;
/* unpack_init_data(FALSE, unpack_data); */
ppm_constructor(&unpack_data->ppm_data);
@ -1456,7 +1467,7 @@ rar_metadata_t *cli_unrar(int fd, const char *dirname, const struct cl_limits *l
if (file_header->flags & LHD_PASSWORD) {
cli_dbgmsg("PASSWORDed file: %s\n", file_header->filename);
metadata_tail->encrypted = TRUE;
} else if (file_header->unpack_size) {
} else /*if (file_header->unpack_size)*/ {
snprintf(filename, 1024, "%s/%lu.ura", dirname, file_count);
ofd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0600);
if (ofd < 0) {

@ -1,7 +1,7 @@
/*
* Extract RAR archives
*
* Copyright (C) 2005 trog@uncon.org
* Copyright (C) 2005-2006 trog@uncon.org
*
* This code is based on the work of Alexander L. Roshal
*
@ -71,31 +71,32 @@ typedef struct rar_metadata_tag
#define SIZEOF_BEEAHEAD 24
#define SIZEOF_STREAMHEAD 26
#define MHD_VOLUME 0x0001
#define MHD_COMMENT 0x0002
#define MHD_LOCK 0x0004
#define MHD_SOLID 0x0008
#define MHD_PACK_COMMENT 0x0010
#define MHD_NEWNUMBERING 0x0010
#define MHD_AV 0x0020
#define MHD_PROTECT 0x0040
#define MHD_PASSWORD 0x0080
#define MHD_FIRSTVOLUME 0x0100
#define MHD_VOLUME 0x0001
#define MHD_COMMENT 0x0002
#define MHD_LOCK 0x0004
#define MHD_SOLID 0x0008
#define MHD_PACK_COMMENT 0x0010
#define MHD_NEWNUMBERING 0x0010
#define MHD_AV 0x0020
#define MHD_PROTECT 0x0040
#define MHD_PASSWORD 0x0080
#define MHD_FIRSTVOLUME 0x0100
#define MHD_ENCRYPTVER 0x0200
#define LHD_SPLIT_BEFORE 0x0001
#define LHD_SPLIT_AFTER 0x0002
#define LHD_PASSWORD 0x0004
#define LHD_COMMENT 0x0008
#define LHD_SOLID 0x0010
#define LHD_SPLIT_BEFORE 0x0001
#define LHD_SPLIT_AFTER 0x0002
#define LHD_PASSWORD 0x0004
#define LHD_COMMENT 0x0008
#define LHD_SOLID 0x0010
#define LONG_BLOCK 0x8000
#define LONG_BLOCK 0x8000
#define NC 299 /* alphabet = {0, 1, 2, ..., NC - 1} */
#define DC 60
#define RC 28
#define LDC 17
#define BC 20
#define HUFF_TABLE_SIZE (NC+DC+RC+LDC)
#define NC 299 /* alphabet = {0, 1, 2, ..., NC - 1} */
#define DC 60
#define RC 28
#define LDC 17
#define BC 20
#define HUFF_TABLE_SIZE (NC+DC+RC+LDC)
#define MAX_BUF_SIZE 32768
#define MAXWINSIZE 0x400000
@ -113,8 +114,8 @@ typedef struct main_header_tag
uint8_t head_type __attribute__ ((packed));
uint16_t flags __attribute__ ((packed));
uint16_t head_size __attribute__ ((packed));
uint16_t reserved __attribute__ ((packed));
uint32_t reserved1 __attribute__ ((packed));
uint16_t highposav __attribute__ ((packed));
uint32_t posav __attribute__ ((packed));
} main_header_t;
typedef struct file_header_tag

@ -1,7 +1,7 @@
/*
* Extract RAR archives
*
* Copyright (C) 2005 trog@uncon.org
* Copyright (C) 2005-2006 trog@uncon.org
*
* This code is based on the work of Alexander L. Roshal
*
@ -39,14 +39,15 @@ static void cli_dbgmsg(){};
static void rar_dbgmsg(){};
#endif
const unsigned int UNIT_SIZE=sizeof(struct ppm_context);
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
const unsigned int UNIT_SIZE=MAX(sizeof(struct ppm_context), sizeof(struct rar_mem_blk_tag));
const unsigned int FIXED_UNIT_SIZE=12;
const int INT_BITS=7, PERIOD_BITS=7, TOT_BITS=14, MAX_O=64;
const int INTERVAL=1 << 7, BIN_SCALE=1 << 14, MAX_FREQ=124;
const unsigned int TOP=1 << 24, BOT=1 << 15;
/************* Start of Allocator code block ********************/
static void sub_allocator_init(sub_allocator_t *sub_alloc)
{
sub_alloc->sub_allocator_size = 0;
@ -72,6 +73,11 @@ static int sub_allocator_u2b(int nu)
return UNIT_SIZE*nu;
}
static rar_mem_blk_t* sub_allocator_mbptr(rar_mem_blk_t* base_ptr, int items)
{
return ((rar_mem_blk_t*) (((unsigned char *)(base_ptr)) + sub_allocator_u2b(items) ));
}
static void sub_allocator_split_block(sub_allocator_t *sub_alloc, void *pv,
int old_indx, int new_indx)
{
@ -186,19 +192,20 @@ static void sub_allocator_glue_free_blocks(sub_allocator_t *sub_alloc)
}
for (p=s0.next ; p != &s0 ; p=p->next) {
while ((p1 = p+p->nu)->stamp == 0xFFFF && ((int)p->nu)+p1->nu < 0x10000) {
while ((p1 = sub_allocator_mbptr(p,p->nu))->stamp == 0xFFFF &&
((int)p->nu)+p1->nu < 0x10000) {
rar_mem_blk_remove(p1);
p->nu += p1->nu;
}
}
while ((p=s0.next) != &s0) {
for (rar_mem_blk_remove(p), sz=p->nu; sz > 128; sz-=128, p+=128) {
for (rar_mem_blk_remove(p), sz=p->nu; sz > 128; sz-=128, p=sub_allocator_mbptr(p, 128)) {
sub_allocator_insert_node(sub_alloc, p, N_INDEXES-1);
}
if (sub_alloc->indx2units[i=sub_alloc->units2indx[sz-1]] != sz) {
k = sz-sub_alloc->indx2units[--i];
sub_allocator_insert_node(sub_alloc, p+(sz-k), k-1);
sub_allocator_insert_node(sub_alloc, sub_allocator_mbptr(p,sz-k), k-1);
}
sub_allocator_insert_node(sub_alloc, p, i);
}
@ -969,6 +976,10 @@ int ppm_decode_char(ppm_data_t *ppm_data, int fd, unpack_data_t *unpack_data)
return -1;
}
if (ppm_data->min_context->num_stats != 1) {
if (ppm_data->min_context->con_ut.u.stats <= ppm_data->sub_alloc.ptext ||
ppm_data->min_context->con_ut.u.stats > ppm_data->sub_alloc.heap_end) {
return -1;
}
if (!ppm_decode_symbol1(ppm_data, ppm_data->min_context)) {
return -1;
}

@ -1,7 +1,7 @@
/*
* Extract RAR archives
*
* Copyright (C) 2005 trog@uncon.org
* Copyright (C) 2005-2006 trog@uncon.org
*
* This code is based on the work of Alexander L. Roshal
*
@ -1067,6 +1067,7 @@ int rarvm_prepare(rarvm_data_t *rarvm_data, rarvm_input_t *rarvm_input, unsigned
cur_cmd->op1.data = filter_type;
cur_cmd->op1.addr = &cur_cmd->op1.data;
cur_cmd->op2.addr = &cur_cmd->op2.data;
cur_cmd->op1.type = cur_cmd->op2.type = VM_OPNONE;
code_size = 0;
}
@ -1153,6 +1154,7 @@ int rarvm_prepare(rarvm_data_t *rarvm_data, rarvm_input_t *rarvm_input, unsigned
cur_cmd->op_code = VM_RET;
cur_cmd->op1.addr = &cur_cmd->op1.data;
cur_cmd->op2.addr = &cur_cmd->op2.data;
cur_cmd->op1.type = cur_cmd->op2.type = VM_OPNONE;
for (i=0 ; i < prg->cmd_count ; i++) {
cmd = &prg->cmd.array[i];

Loading…
Cancel
Save