mirror of
https://github.com/facebook/zstd.git
synced 2025-11-27 11:41:11 +03:00
[ldm] Add TODO and comment for segfaulting in compress function
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
#define RUN_MASK ((1U<<RUN_BITS)-1)
|
#define RUN_MASK ((1U<<RUN_BITS)-1)
|
||||||
|
|
||||||
#define COMPUTE_STATS
|
#define COMPUTE_STATS
|
||||||
#define CHECKSUM_CHAR_OFFSET 2
|
#define CHECKSUM_CHAR_OFFSET 0
|
||||||
//#define RUN_CHECKS
|
//#define RUN_CHECKS
|
||||||
//#define LDM_DEBUG
|
//#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.
|
// This is based upon lz4.
|
||||||
size_t LDM_compress(const void *src, size_t srcSize,
|
size_t LDM_compress(const void *src, size_t srcSize,
|
||||||
void *dst, size_t maxDstSize) {
|
void *dst, size_t maxDstSize) {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// TODO: file size must fit into a U32
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -12,12 +10,17 @@
|
|||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "ldm.h"
|
#include "ldm.h"
|
||||||
|
#include "zstd.h"
|
||||||
|
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
//#define TEST
|
//#define TEST
|
||||||
|
|
||||||
/* Compress file given by fname and output to oname.
|
/* Compress file given by fname and output to oname.
|
||||||
* Returns 0 if successful, error code otherwise.
|
* 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) {
|
static int compress(const char *fname, const char *oname) {
|
||||||
int fdin, fdout;
|
int fdin, fdout;
|
||||||
@@ -78,10 +81,9 @@ static int compress(const char *fname, const char *oname) {
|
|||||||
dst + LDM_HEADER_SIZE, statbuf.st_size);
|
dst + LDM_HEADER_SIZE, statbuf.st_size);
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
compressSize = LDM_HEADER_SIZE +
|
compressSize = LDM_HEADER_SIZE +
|
||||||
LDM_compress(src, statbuf.st_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
|
// Write compress and decompress size to header
|
||||||
// TODO: should depend on LDM_DECOMPRESS_SIZE write32
|
// TODO: should depend on LDM_DECOMPRESS_SIZE write32
|
||||||
|
|||||||
@@ -53,11 +53,6 @@ U32 LDM_read32(const void *ptr) {
|
|||||||
return *(const U32 *)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) {
|
U64 LDM_read64(const void *ptr) {
|
||||||
return *(const U64 *)ptr;
|
return *(const U64 *)ptr;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user