... | ... |
@@ -124,15 +124,3 @@ int cli_LzmaDecode(struct CLI_LZMA *L) { |
124 | 124 |
return LZMA_STREAM_END; |
125 | 125 |
return LZMA_RESULT_OK; |
126 | 126 |
} |
127 |
- |
|
128 |
- |
|
129 |
-int cli_LzmaInitUPX(struct CLI_LZMA *L, uint32_t dsz) { |
|
130 |
- unsigned char fake_hdr[5]; |
|
131 |
- unsigned char *next_in = L->next_in; |
|
132 |
- SizeT avail_in = L->avail_in; |
|
133 |
- cli_writeint32(fake_hdr + 1, dsz); |
|
134 |
- *fake_hdr = 9 /* lc */ + 9* ( 5* 2 /* pb */ + 0 /* lp */); |
|
135 |
- L->next_in = fake_hdr; |
|
136 |
- L->avail_in = 5; |
|
137 |
- return cli_LzmaInit(L, dsz); |
|
138 |
-} |
... | ... |
@@ -52,7 +52,6 @@ struct stream_state { |
52 | 52 |
int cli_LzmaInit(struct CLI_LZMA *, uint64_t); |
53 | 53 |
void cli_LzmaShutdown(struct CLI_LZMA *); |
54 | 54 |
int cli_LzmaDecode(struct CLI_LZMA *); |
55 |
-int cli_LzmaInitUPX(struct CLI_LZMA *, uint32_t); |
|
56 | 55 |
|
57 | 56 |
#define LZMA_STREAM_END 2 |
58 | 57 |
#define LZMA_RESULT_OK 0 |
... | ... |
@@ -524,15 +524,20 @@ int upx_inflate2e(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_ |
524 | 524 |
|
525 | 525 |
int upx_inflatelzma(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t upx0, uint32_t upx1, uint32_t ep) { |
526 | 526 |
struct CLI_LZMA l; |
527 |
- struct stream_state s; |
|
528 | 527 |
uint32_t magic[]={0xb16,0xb1e,0}; |
528 |
+ unsigned char fake_lzmahdr[5]; |
|
529 | 529 |
|
530 | 530 |
memset(&l, 0, sizeof(l)); |
531 |
- cli_LzmaInitUPX(&l, *dsize); /* FIXMELZMA: check return value */ |
|
532 |
- s.avail_in = ssize; |
|
533 |
- s.avail_out = *dsize; |
|
534 |
- s.next_in = (unsigned char*)src+2; |
|
535 |
- s.next_out = (unsigned char*)dst; |
|
531 |
+ cli_writeint32(fake_lzmahdr + 1, *dsize); |
|
532 |
+ *fake_lzmahdr = 3 /* lc */ + 9* ( 5* 2 /* pb */ + 0 /* lp */); |
|
533 |
+ l.next_in = fake_lzmahdr; |
|
534 |
+ l.avail_in = 5; |
|
535 |
+ if(cli_LzmaInit(&l, *dsize) != LZMA_RESULT_OK) |
|
536 |
+ return 0; |
|
537 |
+ l.avail_in = ssize; |
|
538 |
+ l.avail_out = *dsize; |
|
539 |
+ l.next_in = (unsigned char*)src+2; |
|
540 |
+ l.next_out = (unsigned char*)dst; |
|
536 | 541 |
|
537 | 542 |
if(cli_LzmaDecode(&l)==LZMA_RESULT_DATA_ERROR) { |
538 | 543 |
/* __asm__ __volatile__("int3"); */ |