fix some mistakes but still the same segfault
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,4 +1,4 @@
|
||||
CFLAGS=-Wall -Wextra
|
||||
CFLAGS=-Wall -Wextra -g
|
||||
LZMA_CFLAGS=-Wall -Wextra -O3
|
||||
all: kpack_c
|
||||
kpack_c: kpack_c.o LZMAEncoder.o MatchFinder.o RangeCoder.o
|
||||
|
17
kpack_c.c
17
kpack_c.c
@@ -50,13 +50,16 @@ unsigned preprocess_calltrick(unsigned char *infile, unsigned insize, unsigned c
|
||||
if (buf == NULL) {
|
||||
goto pack_calltrick_fail;
|
||||
}
|
||||
*ctn = 0;
|
||||
*cti = 0;
|
||||
memset(ct1, 0, 256);
|
||||
|
||||
unsigned char *infile_ptr = infile;
|
||||
unsigned count = insize;
|
||||
unsigned char *buf_ptr = buf;
|
||||
do {
|
||||
unsigned al = *infile_ptr++;
|
||||
//printf("infile_ptr = %p, count = %u\n", infile_ptr, count);
|
||||
unsigned al = *(infile_ptr++);
|
||||
al -= 0x0E8;
|
||||
if (al > 1) {
|
||||
continue;
|
||||
@@ -76,8 +79,8 @@ unsigned preprocess_calltrick(unsigned char *infile, unsigned insize, unsigned c
|
||||
num = byteswap(num);
|
||||
memcpy(infile_ptr - 4, &num, 4);
|
||||
(*ctn)++;
|
||||
memcpy(buf_ptr, &infile_ptr, 4);
|
||||
buf_ptr += 8;
|
||||
memcpy(buf_ptr, &infile_ptr, sizeof(buf_ptr));
|
||||
buf_ptr += sizeof(buf_ptr);
|
||||
}
|
||||
|
||||
} while(count > 0);
|
||||
@@ -91,11 +94,11 @@ unsigned preprocess_calltrick(unsigned char *infile, unsigned insize, unsigned c
|
||||
}
|
||||
*cti = ~(unsigned char)256;
|
||||
|
||||
unsigned tmp;
|
||||
unsigned char *tmp;
|
||||
while (buf_ptr != buf) {
|
||||
buf_ptr -= 8;
|
||||
memcpy(&tmp, buf_ptr, 4);
|
||||
memcpy((unsigned char*)(size_t)(tmp - 4), cti, 1);
|
||||
buf_ptr -= sizeof(tmp);
|
||||
memcpy(&tmp, buf_ptr, sizeof(tmp));
|
||||
memcpy(tmp - 4, cti, 1);
|
||||
}
|
||||
free(buf);
|
||||
return tmp;
|
||||
|
Reference in New Issue
Block a user