|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
|
|
|
* Copyright (C) 2015, 2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
|
|
|
|
* Copyright (C) 2010 Sourcefire, Inc. |
|
|
|
|
* |
|
|
|
|
* Authors: aCaB <acab@clamav.net> |
|
|
|
@ -50,11 +50,11 @@ static const uint8_t hqxtbl[] = { |
|
|
|
|
|
|
|
|
|
int cli_binhex(cli_ctx *ctx) { |
|
|
|
|
fmap_t *map = *ctx->fmap; |
|
|
|
|
const uint8_t *encoded; |
|
|
|
|
uint8_t decoded[BUFSIZ], spare_bits, last_byte=0, this_byte, offset=0; |
|
|
|
|
const uint8_t *encoded = NULL; |
|
|
|
|
uint8_t decoded[BUFSIZ], spare_bits = 0, last_byte = 0, this_byte = 0, offset = 0; |
|
|
|
|
size_t enc_done=0, enc_todo=map->len; |
|
|
|
|
unsigned int dec_done=0, chunksz = 0, chunkoff=0; |
|
|
|
|
uint32_t datalen, reslen; |
|
|
|
|
uint32_t datalen = 0, reslen = 0; |
|
|
|
|
int in_data = 0, in_run = 0, datafd, resfd, ret = CL_CLEAN; |
|
|
|
|
enum binhex_phase { IN_BANNER, IN_HEADER, IN_DATA, IN_LIMBO1, IN_LIMBO2, IN_RES } write_phase = IN_BANNER; |
|
|
|
|
char *dname, *rname; |
|
|
|
@ -188,7 +188,10 @@ int cli_binhex(cli_ctx *ctx) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!chunksz) { |
|
|
|
|
// 'chunksz' must be 0 the first iteration,
|
|
|
|
|
// so that 'encoded' will be initialized before first dereference.
|
|
|
|
|
if(!chunksz) |
|
|
|
|
{ |
|
|
|
|
chunksz = MIN(enc_todo, map->pgsz); |
|
|
|
|
encoded = fmap_need_off_once(map, enc_done, chunksz); |
|
|
|
|
if(!encoded) { |
|
|
|
|