cli : new : added zstdless and zstdgrep tools
cli : fixed : status displays total amount decoded, even for file consisting of multiple frames (like pzstd)
cli : fixed : zstdcat
-library : changed : only public ZSTD_ symbols are now exposed
+lib : changed : only public ZSTD_ symbols are now exposed
+lib : fixed : soname
API : changed : zbuff prototypes now generate deprecation warnings
API : changed : streaming decompression implicit reset on starting new frame
API : added experimental : dictID retrieval functions
-#include <stdlib.h> // malloc, exit
-#include <stdio.h> // fprintf, perror
-#include <string.h> // strerror
+#include <stdlib.h> // malloc, free, exit
+#include <stdio.h> // fprintf, perror, fopen, etc.
+#include <string.h> // strlen, strcat, memset, strerror
#include <errno.h> // errno
#include <sys/stat.h> // stat
#include <zstd.h> // presumes zstd library is installed
static void* loadFile_orDie(const char* fileName, size_t* size)
{
- off_t const buffSize = fsize_orDie(fileName);
+ off_t const fileSize = fsize_orDie(fileName);
+ size_t const buffSize = (size_t)fileSize;
+ if ((off_t)buffSize < fileSize) { /* narrowcast overflow */
+ fprintf(stderr, "%s : filesize too large \n", fileName);
+ exit(4);
+ }
FILE* const inFile = fopen_orDie(fileName, "rb");
void* const buffer = malloc_orDie(buffSize);
size_t const readSize = fread(buffer, 1, buffSize, inFile);
if (readSize != (size_t)buffSize) {
fprintf(stderr, "fread: %s : %s \n", fileName, strerror(errno));
- exit(4);
+ exit(5);
}
fclose(inFile); /* can't fail, read only */
*size = buffSize;
size_t const wSize = fwrite(buff, 1, buffSize, oFile);
if (wSize != (size_t)buffSize) {
fprintf(stderr, "fwrite: %s : %s \n", fileName, strerror(errno));
- exit(5);
+ exit(6);
}
if (fclose(oFile)) {
perror(fileName);
- exit(6);
+ exit(7);
}
}
size_t const cSize = ZSTD_compress(cBuff, cBuffSize, fBuff, fSize, 1);
if (ZSTD_isError(cSize)) {
fprintf(stderr, "error compressing %s : %s \n", fname, ZSTD_getErrorName(cSize));
- exit(7);
+ exit(8);
}
saveFile_orDie(oname, cBuff, cSize);
SHARED_EXT = dylib
SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
- SONAME_FLAGS = -install_name $(PREFIX)/lib/$@.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
+ SONAME_FLAGS = -install_name $(PREFIX)/lib/libzstd.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
else
- SONAME_FLAGS = -Wl,-soname=$@.$(SHARED_EXT).$(LIBVER_MAJOR)
+ SONAME_FLAGS = -Wl,-soname=libzstd.$(SHARED_EXT).$(LIBVER_MAJOR)
SHARED_EXT = so
SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)