libsheepy

C lib for handling text files, strings and json like data structure with an object oriented system
git clone https://spartatek.se/git/libsheepy.git
Log | Files | Refs | README | LICENSE

commit ed462ae7949f6d9a1f88f5e764df067e5c5d6792
parent d6414473bca896054ca7e4eec16ba5ceca934f86
Author: Remy Noulin <loader2x@gmail.com>
Date:   Thu, 15 Jul 2021 19:46:56 +0000

fix bugs discovered in freebsd

release/libsheepy.c | 18 +++++++++++++++++-
release/libsheepy.h |  2 +-
src/libsheepy.c     | 18 +++++++++++++++++-
src/libsheepy.h     |  2 +-
4 files changed, 36 insertions(+), 4 deletions(-)

Diffstat:
Mrelease/libsheepy.c | 18+++++++++++++++++-
Mrelease/libsheepy.h | 2+-
Msrc/libsheepy.c | 18+++++++++++++++++-
Msrc/libsheepy.h | 2+-
4 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/release/libsheepy.c b/release/libsheepy.c @@ -2018,6 +2018,9 @@ char *getCurrentDate(void) { char *bGetCurrentDate(char *dst) { + if (!dst) { + return(NULL); + } time_t _clk = time(NULL);; struct tm *_pClk = localtime(&_clk);; strftime(dst, 80, "%c", _pClk); @@ -2026,6 +2029,9 @@ char *bGetCurrentDate(char *dst) { char *bLGetCurrentDate(char *dst, size_t dstSize) { + if (!dst) { + return(NULL); + } time_t _clk = time(NULL);; struct tm *_pClk = localtime(&_clk);; strftime(dst, dstSize, "%c", _pClk); @@ -2048,6 +2054,9 @@ char *getCurrentDateYMD(void) { char *bGetCurrentDateYMD(char *dst) { + if (!dst) { + return(NULL); + } time_t _clk = time(NULL);; struct tm *_pClk = localtime(&_clk);; strftime(dst, 80, "%Y-%m-%d %H:%M:%S", _pClk); @@ -2056,6 +2065,9 @@ char *bGetCurrentDateYMD(char *dst) { char *bLGetCurrentDateYMD(char *dst, size_t dstSize) { + if (!dst) { + return(NULL); + } time_t _clk = time(NULL);; struct tm *_pClk = localtime(&_clk);; strftime(dst, dstSize, "%Y-%m-%d %H:%M:%S", _pClk); @@ -5483,7 +5495,9 @@ int copy(const char* src, const char* dst) { // copy file if (getS(dst, -1) == '/') { // dst name is a directory, add src basename to dst - char *path = basename((char*)src); + char *csrc = strdup(src); + char *path = basename(csrc); + free(csrc); char *dPath = alloca(strlen(dst) + 1 + strlen(path) + 1); sprintf(dPath, "%s/%s", dst, path); return(copyFile(src, dPath)); @@ -5506,7 +5520,9 @@ int copy(const char* src, const char* dst) { return(copyADir(src, dst, "")); } else { + char *csrc = strdup(src); char *path = basename((char*)src); + free(csrc); char *dPath = alloca(strlen(dst) + 1 + strlen(path) + 1); sprintf(dPath, "%s/%s", dst, path); diff --git a/release/libsheepy.h b/release/libsheepy.h @@ -98,7 +98,7 @@ // version accoring to the version package: Release.Major.minor.patch // https://noulin.net/version/file/README.md.html -#define LIBSHEEPY_VERSION "2.2.5.4" +#define LIBSHEEPY_VERSION "2.2.5.5" #ifndef SH_PREFIX #define SH_PREFIX(NAME) NAME diff --git a/src/libsheepy.c b/src/libsheepy.c @@ -2074,6 +2074,9 @@ char *getCurrentDate(void) { char *bGetCurrentDate(char *dst) { + if (!dst) { + return(NULL); + } time_t _clk = time(NULL);; struct tm *_pClk = localtime(&_clk);; strftime(dst, 80, "%c", _pClk); @@ -2082,6 +2085,9 @@ char *bGetCurrentDate(char *dst) { char *bLGetCurrentDate(char *dst, size_t dstSize) { + if (!dst) { + return(NULL); + } time_t _clk = time(NULL);; struct tm *_pClk = localtime(&_clk);; strftime(dst, dstSize, "%c", _pClk); @@ -2104,6 +2110,9 @@ char *getCurrentDateYMD(void) { char *bGetCurrentDateYMD(char *dst) { + if (!dst) { + return(NULL); + } time_t _clk = time(NULL);; struct tm *_pClk = localtime(&_clk);; strftime(dst, 80, "%Y-%m-%d %H:%M:%S", _pClk); @@ -2112,6 +2121,9 @@ char *bGetCurrentDateYMD(char *dst) { char *bLGetCurrentDateYMD(char *dst, size_t dstSize) { + if (!dst) { + return(NULL); + } time_t _clk = time(NULL);; struct tm *_pClk = localtime(&_clk);; strftime(dst, dstSize, "%Y-%m-%d %H:%M:%S", _pClk); @@ -5539,7 +5551,9 @@ int copy(const char* src, const char* dst) { // copy file if (getS(dst, -1) == '/') { // dst name is a directory, add src basename to dst - char *path = basename((char*)src); + char *csrc = strdup(src); + char *path = basename(csrc); + free(csrc); char *dPath = alloca(strlen(dst) + 1 + strlen(path) + 1); sprintf(dPath, "%s/%s", dst, path); return(copyFile(src, dPath)); @@ -5562,7 +5576,9 @@ int copy(const char* src, const char* dst) { return(copyADir(src, dst, "")); } else { + char *csrc = strdup(src); char *path = basename((char*)src); + free(csrc); char *dPath = alloca(strlen(dst) + 1 + strlen(path) + 1); sprintf(dPath, "%s/%s", dst, path); diff --git a/src/libsheepy.h b/src/libsheepy.h @@ -98,7 +98,7 @@ // version accoring to the version package: Release.Major.minor.patch // https://noulin.net/version/file/README.md.html -#define LIBSHEEPY_VERSION "2.2.5.4" +#define LIBSHEEPY_VERSION "2.2.5.5" #ifndef SH_PREFIX #define SH_PREFIX(NAME) NAME