1 /* 2 * Copyright (C) 2013-2022 Cisco Systems, Inc. and/or its affiliates. All rights reserved. 3 * Copyright (C) 2008-2013 Sourcefire, Inc. 4 * 5 * Authors: Alberto Wu 6 * 7 * Acknowledgements: Written from scratch based on specs from PKWARE: 8 * http://www.pkware.com/documents/casestudies/APPNOTE.TXT 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License version 2 as 12 * published by the Free Software Foundation. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 * MA 02110-1301, USA. 23 */ 24 25 #ifndef __EXPLODE_H 26 #define __EXPLODE_H 27 28 #include "clamav-types.h" 29 30 enum { 31 EXPLODE_EBUFF, 32 EXPLODE_ESTREAM 33 }; 34 35 #define EXPLODE_OK EXPLODE_EBUFF 36 37 enum XPL_STATE { 38 GRABLITS, 39 GRABLENS, 40 GRABDISTS, 41 EXPLODE, 42 EXPLODE_LITCODES, 43 EXPLODE_LITS, 44 EXPLODE_BASEDIST, 45 EXPLODE_DECODEDISTS, 46 EXPLODE_DECODELENS, 47 EXPLODE_DECODEEXTRA, 48 EXPLODE_WBYTE, 49 EXPLODE_BACKCOPY 50 }; 51 52 struct xplstate { 53 uint8_t *next_in; 54 uint8_t *next_out; 55 unsigned int got; 56 unsigned int minlen; 57 unsigned int mask; 58 unsigned int cur; 59 uint32_t lit_tree[256]; 60 uint32_t len_tree[64]; 61 uint32_t dist_tree[64]; 62 uint32_t bitmap; 63 uint32_t avail_in; 64 uint32_t avail_out; 65 uint16_t backbytes; 66 uint16_t backsize; 67 uint8_t window[8192]; 68 enum XPL_STATE state; 69 uint8_t bits; 70 uint8_t largewin; 71 uint8_t litcodes; 72 }; 73 74 int explode_init(struct xplstate *, uint16_t); 75 int explode(struct xplstate *); 76 void explode_shutdown(void); 77 78 #endif /* __EXPLODE_H */ 79