diff --git a/NEWS b/NEWS index b4a200ad6..f6f1ad90b 100644 --- a/NEWS +++ b/NEWS @@ -5,7 +5,8 @@ cli : new : preserve file attributes 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 diff --git a/examples/simple_compression.c b/examples/simple_compression.c index 332ce721b..deb0bbfc4 100644 --- a/examples/simple_compression.c +++ b/examples/simple_compression.c @@ -8,9 +8,9 @@ -#include // malloc, exit -#include // fprintf, perror -#include // strerror +#include // malloc, free, exit +#include // fprintf, perror, fopen, etc. +#include // strlen, strcat, memset, strerror #include // errno #include // stat #include // presumes zstd library is installed @@ -45,13 +45,18 @@ static void* malloc_orDie(size_t size) 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; @@ -65,11 +70,11 @@ static void saveFile_orDie(const char* fileName, const void* buff, size_t buffSi 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); } } @@ -84,7 +89,7 @@ static void compress_orDie(const char* fname, const char* oname) 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); diff --git a/lib/Makefile b/lib/Makefile index 44c64b8ed..21a805d05 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -47,9 +47,9 @@ ifeq ($(shell uname), Darwin) 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)