[ldm] Add TODO and comment for segfaulting in compress function

dev
Stella Lau 2017-07-13 10:38:19 -07:00
parent 92bed4a7e0
commit 68c4560701
3 changed files with 11 additions and 11 deletions

View File

@ -28,7 +28,7 @@
#define RUN_MASK ((1U<<RUN_BITS)-1)
#define COMPUTE_STATS
#define CHECKSUM_CHAR_OFFSET 2
#define CHECKSUM_CHAR_OFFSET 0
//#define RUN_CHECKS
//#define LDM_DEBUG
@ -470,7 +470,10 @@ static void outputBlock(LDM_CCtx *cctx,
}
}
// TODO: srcSize and maxDstSize is unused
// TODO: maxDstSize is unused. This function may seg fault when writing
// beyond the size of dst, as it does not check maxDstSize. Writing to
// a buffer and performing checks is a possible solution.
//
// This is based upon lz4.
size_t LDM_compress(const void *src, size_t srcSize,
void *dst, size_t maxDstSize) {

View File

@ -1,5 +1,3 @@
// TODO: file size must fit into a U32
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -12,12 +10,17 @@
#include <fcntl.h>
#include "ldm.h"
#include "zstd.h"
#define DEBUG
//#define TEST
/* Compress file given by fname and output to oname.
* Returns 0 if successful, error code otherwise.
*
* TODO: This currently seg faults if the compressed size is > the decompress
* size due to the mmapping and output file size allocated to be the input size.
* The compress function should check before writing or buffer writes.
*/
static int compress(const char *fname, const char *oname) {
int fdin, fdout;
@ -78,10 +81,9 @@ static int compress(const char *fname, const char *oname) {
dst + LDM_HEADER_SIZE, statbuf.st_size);
#endif
*/
compressSize = LDM_HEADER_SIZE +
LDM_compress(src, statbuf.st_size,
dst + LDM_HEADER_SIZE, statbuf.st_size);
dst + LDM_HEADER_SIZE, maxCompressSize);
// Write compress and decompress size to header
// TODO: should depend on LDM_DECOMPRESS_SIZE write32

View File

@ -53,11 +53,6 @@ U32 LDM_read32(const void *ptr) {
return *(const U32 *)ptr;
}
//TODO: endianness?
void LDM_write64(void *memPtr, U64 value) {
memcpy(memPtr, &value, sizeof(value));
}
U64 LDM_read64(const void *ptr) {
return *(const U64 *)ptr;
}