mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-25 00:25:48 +08:00
lz4stream info to int: use memcpy
This commit is contained in:
parent
cce2e7aad3
commit
d48fcbf5eb
2 changed files with 5 additions and 9 deletions
|
@ -190,10 +190,8 @@ bool FpgaSetupSscDma(uint8_t *buf, int len) {
|
|||
static int get_from_fpga_combined_stream(lz4_streamp compressed_fpga_stream, uint8_t *output_buffer) {
|
||||
if (fpga_image_ptr == output_buffer + FPGA_RING_BUFFER_BYTES) { // need more data
|
||||
fpga_image_ptr = output_buffer;
|
||||
int cmp_bytes = *(compressed_fpga_stream->next_in + 3);
|
||||
cmp_bytes = (cmp_bytes << 8) + *(compressed_fpga_stream->next_in+2);
|
||||
cmp_bytes = (cmp_bytes << 8) + *(compressed_fpga_stream->next_in+1);
|
||||
cmp_bytes = (cmp_bytes << 8) + *(compressed_fpga_stream->next_in+0);
|
||||
int cmp_bytes;
|
||||
memcpy(&cmp_bytes, compressed_fpga_stream->next_in, sizeof(int));
|
||||
compressed_fpga_stream->next_in += 4;
|
||||
compressed_fpga_stream->avail_in -= cmp_bytes + 4;
|
||||
int res = LZ4_decompress_safe_continue(compressed_fpga_stream->lz4StreamDecode,
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "appmain.h"
|
||||
#include "lz4.h"
|
||||
#include "BigBuf.h"
|
||||
#include "string.h"
|
||||
|
||||
static uint8_t *next_free_memory;
|
||||
extern struct common_area common_area;
|
||||
|
@ -23,11 +24,8 @@ extern char __data_src_start__, __data_start__, __data_end__, __bss_start__, __b
|
|||
|
||||
static void uncompress_data_section(void) {
|
||||
next_free_memory = BigBuf_get_addr();
|
||||
|
||||
int avail_in = *(&__data_start__ + 3);
|
||||
avail_in = (avail_in << 8) + *(&__data_start__+2);
|
||||
avail_in = (avail_in << 8) + *(&__data_start__+1);
|
||||
avail_in = (avail_in << 8) + *(&__data_start__+0); // compressed size. Correct.
|
||||
int avail_in;
|
||||
memcpy(&avail_in, &__data_start__, sizeof(int));
|
||||
int avail_out = &__data_end__ - &__data_start__; // uncompressed size. Correct.
|
||||
// uncompress data segment to RAM
|
||||
int res = LZ4_decompress_safe(&__data_src_start__ + 4, &__data_start__, avail_in, avail_out);
|
||||
|
|
Loading…
Reference in a new issue