diff options
Diffstat (limited to 'src')
117 files changed, 186 insertions, 2 deletions
diff --git a/src/inttypes/strtoimax.c b/src/inttypes/strtoimax.c index 2185f293..01a8bfdb 100644 --- a/src/inttypes/strtoimax.c +++ b/src/inttypes/strtoimax.c @@ -2,11 +2,13 @@ #include <ctype.h> #include <errno.h> #include <inttypes.h> +#include <string.h> #include "_safety.h" intmax_t strtoimax(const char * restrict nptr, char ** restrict endptr, int base) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(nptr, strlen(nptr), endptr, sizeof(*endptr)); intmax_t ret = 0; intmax_t max = INTMAX_MAX; diff --git a/src/inttypes/strtoumax.c b/src/inttypes/strtoumax.c index 2889f109..77ae2f10 100644 --- a/src/inttypes/strtoumax.c +++ b/src/inttypes/strtoumax.c @@ -2,11 +2,13 @@ #include <ctype.h> #include <errno.h> #include <inttypes.h> +#include <string.h> #include "_safety.h" uintmax_t strtoumax(const char *restrict nptr, char ** restrict endptr, int base) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(nptr, strlen(nptr), endptr, sizeof(*endptr)); uintmax_t ret = 0; uintmax_t max = UINTMAX_MAX; diff --git a/src/inttypes/wcstoimax.c b/src/inttypes/wcstoimax.c index d49bf663..b75e61ca 100644 --- a/src/inttypes/wcstoimax.c +++ b/src/inttypes/wcstoimax.c @@ -9,6 +9,7 @@ intmax_t wcstoimax(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(nptr, wcslen(nptr), endptr, sizeof(*endptr)); intmax_t ret = 0; intmax_t max = INTMAX_MAX; diff --git a/src/inttypes/wcstoumax.c b/src/inttypes/wcstoumax.c index de1f1058..59788f90 100644 --- a/src/inttypes/wcstoumax.c +++ b/src/inttypes/wcstoumax.c @@ -9,6 +9,7 @@ uintmax_t wcstoumax(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(nptr, wcslen(nptr), endptr, sizeof(*endptr)); uintmax_t ret = 0; uintmax_t max = UINTMAX_MAX; diff --git a/src/stdio/fgetpos.c b/src/stdio/fgetpos.c index 65b35cf7..8e6d201e 100644 --- a/src/stdio/fgetpos.c +++ b/src/stdio/fgetpos.c @@ -6,6 +6,7 @@ int fgetpos(FILE * restrict stream, fpos_t * restrict pos) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(stream, sizeof(*stream), pos, sizeof(*pos)); flockfile(stream); *pos = stream->pos; diff --git a/src/stdio/fgets.c b/src/stdio/fgets.c index 195e724a..68ca7750 100644 --- a/src/stdio/fgets.c +++ b/src/stdio/fgets.c @@ -7,6 +7,7 @@ char * fgets(char * restrict s, int n, FILE * restrict stream) { int i = 0; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(s, n, stream, sizeof(*stream)); if (feof(stream)) { return NULL; diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c index e2ff7efc..4c9eabd7 100644 --- a/src/stdio/fopen.c +++ b/src/stdio/fopen.c @@ -1,6 +1,7 @@ #include <errno.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "_stdio.h" /** open a file stream **/ @@ -11,6 +12,7 @@ FILE * fopen(const char * restrict filename, const char * restrict mode) size_t i; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(filename, strlen(filename), mode, strlen(mode)); for (i = 0; i < FOPEN_MAX; i++) { if (__stdio.FILES[i].bmode == 0) { diff --git a/src/stdio/fopen_s.c b/src/stdio/fopen_s.c index 411f6bbf..e74b7abd 100644 --- a/src/stdio/fopen_s.c +++ b/src/stdio/fopen_s.c @@ -1,7 +1,7 @@ #include <stdio.h> -#include "_stdio.h" #include <string.h> #include <stdlib.h> +#include "_stdio.h" /** open a file stream **/ errno_t fopen_s(FILE * restrict * restrict streamptr, @@ -9,6 +9,8 @@ errno_t fopen_s(FILE * restrict * restrict streamptr, const char * restrict mode) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(streamptr, sizeof(*streamptr), filename, strlen(filename)); + ASSERT_NOOVERLAP(streamptr, sizeof(*streamptr), mode, strlen(mode)); (void)streamptr; (void)filename; (void)mode; return 0; } diff --git a/src/stdio/fprintf.c b/src/stdio/fprintf.c index 72bca8c4..f7a0bc9c 100644 --- a/src/stdio/fprintf.c +++ b/src/stdio/fprintf.c @@ -1,5 +1,6 @@ #include <stdarg.h> #include <stdio.h> +#include <string.h> #include "_stdio.h" /** write formatted output to a file stream **/ @@ -11,6 +12,7 @@ int fprintf(FILE * restrict stream, const char * restrict format, ...) struct io_options opt = {0}; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(stream, sizeof(*stream), format, strlen(format)); opt.fnname = "fprintf"; opt.stream = stream; diff --git a/src/stdio/fprintf_s.c b/src/stdio/fprintf_s.c index 2e5ed670..83843f78 100644 --- a/src/stdio/fprintf_s.c +++ b/src/stdio/fprintf_s.c @@ -1,11 +1,13 @@ #include <stdio.h> #include <stdarg.h> +#include <string.h> #include "_stdio.h" /** write formatted output to a file stream **/ int fprintf_s(FILE * restrict stream, const char * restrict format, ...) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(stream, sizeof(*stream), format, strlen(format)); int retval; va_list ap; va_start(ap, format); diff --git a/src/stdio/fputs.c b/src/stdio/fputs.c index a82338d1..c4d32dec 100644 --- a/src/stdio/fputs.c +++ b/src/stdio/fputs.c @@ -1,4 +1,5 @@ #include <stdio.h> +#include <string.h> #include "_stdio.h" /** write a string to a file stream **/ @@ -6,6 +7,8 @@ int fputs(const char * restrict s, FILE * restrict stream) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(s, strlen(s), stream, sizeof(*stream)); + flockfile(stream); while (*s) { if (fputc(*s++, stream) == EOF) { diff --git a/src/stdio/fread.c b/src/stdio/fread.c index 5b7f38b4..7ddf358f 100644 --- a/src/stdio/fread.c +++ b/src/stdio/fread.c @@ -9,6 +9,7 @@ size_t fread(void * restrict ptr, size_t size, size_t nmemb, FILE * restrict str size_t n = 0; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(ptr, size * nmemb, stream, sizeof(*stream)); flockfile(stream); while (nmemb) { diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c index b40eb439..d361023a 100644 --- a/src/stdio/freopen.c +++ b/src/stdio/freopen.c @@ -55,6 +55,9 @@ FILE * freopen(const char * restrict filename, const char * restrict mode, FILE int fd = -1; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(filename, strlen(filename), mode, strlen(mode)); + ASSERT_NOOVERLAP(filename, strlen(filename), stream, sizeof(*stream)); + ASSERT_NOOVERLAP(mode, strlen(mode), stream, sizeof(*stream)); for (i = 0; i < sizeof(modemap) / sizeof(modemap[0]); i++) { if (!strcmp(modemap[i].smode, mode)) { diff --git a/src/stdio/fscanf.c b/src/stdio/fscanf.c index 98dbeed1..2299fd11 100644 --- a/src/stdio/fscanf.c +++ b/src/stdio/fscanf.c @@ -1,5 +1,6 @@ #include <stdarg.h> #include <stdio.h> +#include <string.h> #include "_stdio.h" /** read formatted input from a file stream **/ @@ -11,6 +12,7 @@ int fscanf(FILE * restrict stream, const char * restrict format, ...) struct io_options opt = {0}; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(stream, sizeof(*stream), format, strlen(format)); opt.fnname = "fscanf"; opt.stream = stream; diff --git a/src/stdio/fscanf_s.c b/src/stdio/fscanf_s.c index 4d01ba5e..310ca5da 100644 --- a/src/stdio/fscanf_s.c +++ b/src/stdio/fscanf_s.c @@ -1,11 +1,13 @@ #include <stdio.h> #include <stdarg.h> +#include <string.h> #include "_stdio.h" /** read formatted input from a file stream **/ int fscanf_s(FILE * restrict stream, const char * restrict format, ...) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(stream, sizeof(*stream), format, strlen(format)); va_list ap; va_start(ap, format); int ret = vfscanf_s(stream, format, ap); diff --git a/src/stdio/fsetpos.c b/src/stdio/fsetpos.c index ca6cb806..40545061 100644 --- a/src/stdio/fsetpos.c +++ b/src/stdio/fsetpos.c @@ -6,6 +6,8 @@ int fsetpos(FILE *stream, const fpos_t *pos) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(stream, sizeof(*stream), pos, sizeof(*pos)); + (void)stream; (void)pos; /* TODO */ return 1; diff --git a/src/stdio/fwrite.c b/src/stdio/fwrite.c index 52861b00..ab2e0f04 100644 --- a/src/stdio/fwrite.c +++ b/src/stdio/fwrite.c @@ -7,7 +7,9 @@ size_t fwrite(const void * restrict ptr, size_t size, size_t nmemb, FILE * restr { unsigned char *buf = (unsigned char *)ptr; size_t n = 0; + SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(ptr, size * nmemb, stream, sizeof(*stream)); while (nmemb) { size_t i; diff --git a/src/stdio/rename.c b/src/stdio/rename.c index 84d0df35..9a701a1d 100644 --- a/src/stdio/rename.c +++ b/src/stdio/rename.c @@ -1,5 +1,6 @@ #include <errno.h> #include <stdio.h> +#include <string.h> #include "_stdio.h" #include "_syscall.h" @@ -8,6 +9,7 @@ int rename(const char *old, const char *new) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(old, strlen(old), new, strlen(new)); SYSCALL(rename, int, -1, old, new, 0, 0, 0, 0); } diff --git a/src/stdio/setbuf.c b/src/stdio/setbuf.c index ddf38856..38072548 100644 --- a/src/stdio/setbuf.c +++ b/src/stdio/setbuf.c @@ -8,6 +8,7 @@ void setbuf(FILE * restrict stream, char * restrict buf) SIGNAL_SAFE(0); if (buf) { + ASSERT_NOOVERLAP(stream, sizeof(*stream), buf, BUFSIZ); setvbuf(stream, buf, _IOFBF, BUFSIZ); } else { setvbuf(stream, NULL, _IONBF, 0); diff --git a/src/stdio/setvbuf.c b/src/stdio/setvbuf.c index a6f37fb0..b400b266 100644 --- a/src/stdio/setvbuf.c +++ b/src/stdio/setvbuf.c @@ -8,6 +8,7 @@ int setvbuf(FILE *stream, char *buf, int mode, size_t size) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(stream, sizeof(*stream), buf, size); flockfile(stream); diff --git a/src/stdio/snprintf.c b/src/stdio/snprintf.c index 9bf6d17b..4ee9ec7f 100644 --- a/src/stdio/snprintf.c +++ b/src/stdio/snprintf.c @@ -1,10 +1,12 @@ #include <stdio.h> #include <stdarg.h> +#include <string.h> #include "_stdio.h" int snprintf(char * restrict s, size_t n, const char * restrict format, ...) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(s, n, format, strlen(format)); struct io_options opt = { .fnname = __func__, diff --git a/src/stdio/snprintf_s.c b/src/stdio/snprintf_s.c index aa7768f9..b3b8c0fc 100644 --- a/src/stdio/snprintf_s.c +++ b/src/stdio/snprintf_s.c @@ -1,9 +1,11 @@ #include <stdio.h> +#include <string.h> #include "_stdio.h" int snprintf_s( char * restrict s, rsize_t n, const char * restrict format, ...) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(s, n, format, strlen(format)); (void)s; (void)n; (void)format; return 0; } diff --git a/src/stdio/sprintf.c b/src/stdio/sprintf.c index 5b1ad29f..fcb1ddac 100644 --- a/src/stdio/sprintf.c +++ b/src/stdio/sprintf.c @@ -12,6 +12,7 @@ int sprintf(char * restrict s, const char * restrict format, ...) struct io_options opt = {0}; SIGNAL_SAFE(0); + /* overlap can't be detected because the length of s is unknown */ opt.fnname = "sprintf"; opt.string = s; diff --git a/src/stdio/sprintf_s.c b/src/stdio/sprintf_s.c index 81613ecb..e640abf7 100644 --- a/src/stdio/sprintf_s.c +++ b/src/stdio/sprintf_s.c @@ -1,11 +1,13 @@ #include <stdio.h> #include <stdarg.h> +#include <string.h> #include "_stdio.h" /** write formatted output to a string **/ int sprintf_s(char * restrict s, rsize_t n, const char * restrict format, ...) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(s, n, format, strlen(format)); (void)n; diff --git a/src/stdio/sscanf.c b/src/stdio/sscanf.c index 125a49f6..4fab8b61 100644 --- a/src/stdio/sscanf.c +++ b/src/stdio/sscanf.c @@ -1,5 +1,6 @@ #include <stdarg.h> #include <stdio.h> +#include <string.h> #include "_stdio.h" /** read formatted input from a string **/ @@ -11,6 +12,7 @@ int sscanf(const char * restrict s, const char * restrict format, ...) struct io_options opt = {0}; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(s, strlen(s), format, strlen(format)); opt.fnname = "sscanf"; opt.string = (char *)s; diff --git a/src/stdio/sscanf_s.c b/src/stdio/sscanf_s.c index 20249496..08bbd6e5 100644 --- a/src/stdio/sscanf_s.c +++ b/src/stdio/sscanf_s.c @@ -1,11 +1,13 @@ #include <stdio.h> #include <stdarg.h> +#include <string.h> #include "_stdio.h" /** read formatted input from a string **/ int sscanf_s(const char * restrict s, const char * restrict format, ...) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(s, strlen(s), format, strlen(format)); va_list ap; va_start(ap, format); diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index 0e3f9557..91de900d 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c @@ -1,5 +1,6 @@ #include <stdarg.h> #include <stdio.h> +#include <string.h> #include "_stdio.h" /** write formatted output to a file stream **/ @@ -8,7 +9,10 @@ int vfprintf(FILE * restrict stream, const char * restrict format, va_list arg) { int ret = 0; struct io_options opt = {0}; + SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(stream, sizeof(stream), format, strlen(format)); + opt.fnname = "vfprintf"; opt.stream = stream; ret = __printf(&opt, format, arg); diff --git a/src/stdio/vfprintf_s.c b/src/stdio/vfprintf_s.c index 941b03c0..b11f27e8 100644 --- a/src/stdio/vfprintf_s.c +++ b/src/stdio/vfprintf_s.c @@ -1,11 +1,14 @@ #include <stdio.h> #include <stdarg.h> +#include <string.h> #include "_stdio.h" /** write formatted output to a file stream **/ int vfprintf_s(FILE * restrict stream, const char * restrict format, va_list arg) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(stream, sizeof(*stream), format, strlen(format)); + struct io_options opt = { .fnname = __func__, .stream = stream, diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c index 0df43d92..af0dc289 100644 --- a/src/stdio/vfscanf.c +++ b/src/stdio/vfscanf.c @@ -1,9 +1,12 @@ #include <stdio.h> +#include <string.h> #include "_stdio.h" int vfscanf(FILE * restrict stream, const char * restrict format, va_list arg) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(stream, sizeof(*stream), format, strlen(format)); + struct io_options opt = { .fnname = __func__, .stream = stream, diff --git a/src/stdio/vfscanf_s.c b/src/stdio/vfscanf_s.c index ca7b84d1..7654abd3 100644 --- a/src/stdio/vfscanf_s.c +++ b/src/stdio/vfscanf_s.c @@ -1,9 +1,12 @@ #include <stdio.h> +#include <string.h> #include "_stdio.h" int vfscanf_s(FILE * restrict stream, const char * restrict format, va_list arg) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(stream, sizeof(*stream), format, strlen(format)); + (void)stream; (void)format; (void)arg; return 0; } diff --git a/src/stdio/vsnprintf.c b/src/stdio/vsnprintf.c index 3fa18cf4..87deb169 100644 --- a/src/stdio/vsnprintf.c +++ b/src/stdio/vsnprintf.c @@ -1,10 +1,13 @@ #include <stdio.h> #include <stdarg.h> +#include <string.h> #include "_stdio.h" int vsnprintf(char * restrict s, size_t n, const char *format, va_list arg) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(s, n, format, strlen(format)); + struct io_options opt = { .fnname = __func__, .string = s, diff --git a/src/stdio/vsnprintf_s.c b/src/stdio/vsnprintf_s.c index 3d094fe5..2f980931 100644 --- a/src/stdio/vsnprintf_s.c +++ b/src/stdio/vsnprintf_s.c @@ -1,9 +1,12 @@ #include <stdio.h> +#include <string.h> #include "_stdio.h" int vsnprintf_s(char * restrict s, rsize_t n, const char * restrict format, va_list arg) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(s, n, format, strlen(format)); + struct io_options opt = { .fnname = __func__, .string = s, diff --git a/src/stdio/vsprintf.c b/src/stdio/vsprintf.c index ef4d40a0..6edf9f2f 100644 --- a/src/stdio/vsprintf.c +++ b/src/stdio/vsprintf.c @@ -10,6 +10,7 @@ int vsprintf(char *s, const char *format, va_list arg) struct io_options opt = {0}; SIGNAL_SAFE(0); + /* overlap can't be detected because the size of s is unknown */ opt.fnname = "fprintf"; opt.string = s; diff --git a/src/stdio/vsprintf_s.c b/src/stdio/vsprintf_s.c index 02a0899f..38500801 100644 --- a/src/stdio/vsprintf_s.c +++ b/src/stdio/vsprintf_s.c @@ -1,12 +1,14 @@ #include <stdio.h> #include <stdarg.h> #include <stdint.h> +#include <string.h> #include "_stdio.h" /** write formatted output to a string **/ int vsprintf_s(char *s, rsize_t n, const char *format, va_list arg) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(s, n, format, strlen(format)); (void)n; return vsnprintf(s, SIZE_MAX, format, arg); } diff --git a/src/stdio/vsscanf.c b/src/stdio/vsscanf.c index b803e262..183d9f2d 100644 --- a/src/stdio/vsscanf.c +++ b/src/stdio/vsscanf.c @@ -1,10 +1,12 @@ #include <stdio.h> #include <stdarg.h> +#include <string.h> #include "_stdio.h" int vsscanf(const char * restrict s, const char * restrict format, va_list arg) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(s, strlen(s), format, strlen(format)); struct io_options opt = { .fnname = __func__, diff --git a/src/stdio/vsscanf_s.c b/src/stdio/vsscanf_s.c index 3e3ea62f..63ec80bf 100644 --- a/src/stdio/vsscanf_s.c +++ b/src/stdio/vsscanf_s.c @@ -1,9 +1,12 @@ #include <stdarg.h> +#include <string.h> #include "_stdio.h" int vsscanf_s(const char * restrict s, const char * restrict format, va_list arg) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(s, strlen(s), format, strlen(format)); + (void)s; (void)format; (void)arg; return 0; } diff --git a/src/stdlib/bsearch.c b/src/stdlib/bsearch.c index a7531672..ae60783e 100644 --- a/src/stdlib/bsearch.c +++ b/src/stdlib/bsearch.c @@ -12,6 +12,7 @@ void * bsearch(const void * key, const void * base, size_t nmemb, size_t size, i const char *addr = base; SIGNAL_SAFE(0); + /* overlap can't be detected because the size of key can't be known */ while (ret == NULL) { int comp = compar(key, addr + (i * size)); diff --git a/src/stdlib/bsearch_s.c b/src/stdlib/bsearch_s.c index 706aa399..957dbaca 100644 --- a/src/stdlib/bsearch_s.c +++ b/src/stdlib/bsearch_s.c @@ -6,6 +6,7 @@ void *bsearch_s(const void * key, const void * base, rsize_t nmemb, rsize_t size, int (*compar)(const void *x, const void *y, void * context), void *context) { SIGNAL_SAFE(0); + /* Overlap can't be detected because the size of the key and context are unknowable */ /* TODO: testing */ (void)size; diff --git a/src/stdlib/getenv_s.c b/src/stdlib/getenv_s.c index 73e6131c..489bdeea 100644 --- a/src/stdlib/getenv_s.c +++ b/src/stdlib/getenv_s.c @@ -1,11 +1,16 @@ #include <string.h> #include <stdlib.h> +#include <string.h> #include "_stdlib.h" /** get an environment variable **/ errno_t getenv_s(size_t * restrict len, char * restrict value, rsize_t maxsize, const char * restrict name) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(len, sizeof(*len), value, maxsize); + ASSERT_NOOVERLAP(len, sizeof(*len), name, strlen(name)); + ASSERT_NOOVERLAP(value, maxsize, name, strlen(name)); + (void)len; (void)value; (void)maxsize; (void)name; return 0; } diff --git a/src/stdlib/mbstowcs.c b/src/stdlib/mbstowcs.c index c01f8201..61e83512 100644 --- a/src/stdlib/mbstowcs.c +++ b/src/stdlib/mbstowcs.c @@ -6,6 +6,7 @@ size_t mbstowcs(wchar_t * restrict pwcs, const char * restrict s, size_t n) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(pwcs, n * sizeof(*pwcs), s, n); /* FIXME: forward dependency on AMD1 */ #if 0 diff --git a/src/stdlib/mbstowcs_s.c b/src/stdlib/mbstowcs_s.c index 23426796..8270faf6 100644 --- a/src/stdlib/mbstowcs_s.c +++ b/src/stdlib/mbstowcs_s.c @@ -5,6 +5,10 @@ errno_t mbstowcs_s(size_t * restrict retval, wchar_t * restrict dst, rsize_t dstmax, const char * restrict src, rsize_t len) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(retval, sizeof(*retval), dst, dstmax); + ASSERT_NOOVERLAP(retval, sizeof(*retval), src, len); + ASSERT_NOOVERLAP(dst, dstmax, src, len); + (void)retval; (void)dst; (void)dstmax; (void)src; (void)len; return 0; } diff --git a/src/stdlib/mbtowc.c b/src/stdlib/mbtowc.c index 015a4505..c2780bf6 100644 --- a/src/stdlib/mbtowc.c +++ b/src/stdlib/mbtowc.c @@ -6,6 +6,8 @@ int mbtowc(wchar_t * restrict pwc, const char * restrict s, size_t n) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(pwc, sizeof(*pwc), s, n); + /* FIXME: forward dependency on AMD1 */ #if 0 static mbstate_t ps = 0; diff --git a/src/stdlib/qsort_s.c b/src/stdlib/qsort_s.c index 3586dad0..0b871f06 100644 --- a/src/stdlib/qsort_s.c +++ b/src/stdlib/qsort_s.c @@ -7,6 +7,7 @@ errno_t qsort_s(void *base, rsize_t nmemb, rsize_t size, void * context) { SIGNAL_SAFE(0); + /* Overlap can't be detected because size of context is unknowable */ (void)base; (void)nmemb; (void)size; (void)compar; (void)context; return 0; } diff --git a/src/stdlib/strtod.c b/src/stdlib/strtod.c index b259f05c..af7ebbb7 100644 --- a/src/stdlib/strtod.c +++ b/src/stdlib/strtod.c @@ -3,6 +3,7 @@ #include <float.h> #include <math.h> #include <stdlib.h> +#include <string.h> #include "_stdlib.h" #ifndef INFINITY @@ -25,6 +26,7 @@ double strtod(const char * restrict nptr, char ** restrict endptr) double huge = HUGE_VAL; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(nptr, strlen(nptr), endptr, sizeof(*endptr)); #include "_strtod.h" diff --git a/src/stdlib/strtof.c b/src/stdlib/strtof.c index 2dfb8183..cb53b064 100644 --- a/src/stdlib/strtof.c +++ b/src/stdlib/strtof.c @@ -3,6 +3,7 @@ #include <errno.h> #include <ctype.h> #include <math.h> +#include <string.h> #include "_stdlib.h" /** convert string to floating-point **/ @@ -17,6 +18,7 @@ float strtof(const char * restrict nptr, char ** restrict endptr) float nan = NAN; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(nptr, strlen(nptr), endptr, sizeof(*endptr)); #include "_strtod.h" diff --git a/src/stdlib/strtol.c b/src/stdlib/strtol.c index dc2b9d87..525273d9 100644 --- a/src/stdlib/strtol.c +++ b/src/stdlib/strtol.c @@ -2,6 +2,7 @@ #include <errno.h> #include <limits.h> #include <stdlib.h> +#include <string.h> #include "_stdlib.h" /** convert string to long integer **/ @@ -13,6 +14,7 @@ long int strtol(const char * restrict nptr, char ** restrict endptr, int base) long int min = LONG_MIN; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(nptr, strlen(nptr), endptr, sizeof(*endptr)); #include "_strtoi.h" diff --git a/src/stdlib/strtold.c b/src/stdlib/strtold.c index 43fc77bd..b658152b 100644 --- a/src/stdlib/strtold.c +++ b/src/stdlib/strtold.c @@ -3,6 +3,7 @@ #include <ctype.h> #include <errno.h> #include <math.h> +#include <string.h> #include "_stdlib.h" /** convert string to floating-point **/ @@ -17,6 +18,7 @@ long double strtold(const char * restrict nptr, char ** restrict endptr) long double nan = NAN; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(nptr, strlen(nptr), endptr, sizeof(*endptr)); #include "_strtod.h" diff --git a/src/stdlib/strtoll.c b/src/stdlib/strtoll.c index 10f05209..ab5b3d9e 100644 --- a/src/stdlib/strtoll.c +++ b/src/stdlib/strtoll.c @@ -2,6 +2,7 @@ #include <ctype.h> #include <limits.h> #include <errno.h> +#include <string.h> #include "_stdlib.h" long long int strtoll(const char * restrict nptr, char ** restrict endptr, int base) @@ -11,6 +12,7 @@ long long int strtoll(const char * restrict nptr, char ** restrict endptr, int b long long int min = LLONG_MIN; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(nptr, strlen(nptr), endptr, sizeof(*endptr)); #include "_strtoi.h" diff --git a/src/stdlib/strtoul.c b/src/stdlib/strtoul.c index 1270c92c..35c146c3 100644 --- a/src/stdlib/strtoul.c +++ b/src/stdlib/strtoul.c @@ -2,6 +2,7 @@ #include <ctype.h> #include <limits.h> #include <stdlib.h> +#include <string.h> #include "_stdlib.h" /** convert string to unsigned long integer **/ @@ -13,6 +14,7 @@ unsigned long int strtoul(const char * nptr, char ** endptr, int base) unsigned long int min = 0; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(nptr, strlen(nptr), endptr, sizeof(*endptr)); #include "_strtoi.h" diff --git a/src/stdlib/strtoull.c b/src/stdlib/strtoull.c index 2a74df16..994eaba0 100644 --- a/src/stdlib/strtoull.c +++ b/src/stdlib/strtoull.c @@ -2,6 +2,7 @@ #include <ctype.h> #include <limits.h> #include <errno.h> +#include <string.h> #include "_stdlib.h" unsigned long long int strtoull(const char * restrict nptr, char ** restrict endptr, int base) @@ -11,6 +12,7 @@ unsigned long long int strtoull(const char * restrict nptr, char ** restrict end unsigned long long int min = 0; SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(nptr, strlen(nptr), endptr, sizeof(*endptr)); #include "_strtoi.h" diff --git a/src/stdlib/wcstombs.c b/src/stdlib/wcstombs.c index 1d9dd4eb..62524aa3 100644 --- a/src/stdlib/wcstombs.c +++ b/src/stdlib/wcstombs.c @@ -1,4 +1,5 @@ #include <stdlib.h> +#include <wchar.h> #include "_stdlib.h" /** convert wide character string to multibyte string **/ @@ -6,6 +7,7 @@ size_t wcstombs(char * restrict s, const wchar_t * restrict pwcs, size_t n) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(s, n, pwcs, wcslen(pwcs)); (void)s; (void)pwcs; (void)n; /* TODO */ diff --git a/src/stdlib/wcstombs_s.c b/src/stdlib/wcstombs_s.c index d5c830fa..eab4e027 100644 --- a/src/stdlib/wcstombs_s.c +++ b/src/stdlib/wcstombs_s.c @@ -5,6 +5,10 @@ errno_t wcstombs_s(size_t * restrict retval, char * restrict dst, rsize_t dstmax, const wchar_t * restrict src, rsize_t len) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(retval, sizeof(*retval), dst, dstmax); + ASSERT_NOOVERLAP(retval, sizeof(*retval), src, len); + ASSERT_NOOVERLAP(dst, dstmax, src, len); + (void)retval; (void)dst; (void)dstmax; (void)src; (void)len; /* TODO */ return 0; diff --git a/src/stdlib/wctomb_s.c b/src/stdlib/wctomb_s.c index 8027c59d..6303b21e 100644 --- a/src/stdlib/wctomb_s.c +++ b/src/stdlib/wctomb_s.c @@ -5,6 +5,7 @@ errno_t wctomb_s(int * restrict status, char * restrict s, rsize_t smax, wchar_t wc) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(status, sizeof(*status), s, smax); (void)status; (void)s; (void)smax; (void)wc; /* TODO */ return 0; diff --git a/src/string/memcmp.c b/src/string/memcmp.c index 028d2354..f87f849a 100644 --- a/src/string/memcmp.c +++ b/src/string/memcmp.c @@ -12,6 +12,7 @@ int memcmp(const void *s1, const void *s2, size_t n) SIGNAL_SAFE(0); ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); + /* no modifications, so overlap is OK */ for (i = 0; i < n; i++) { if (p[i] != q[i]) { diff --git a/src/string/memmove_s.c b/src/string/memmove_s.c index 0475ee00..a6d84b55 100644 --- a/src/string/memmove_s.c +++ b/src/string/memmove_s.c @@ -8,6 +8,7 @@ errno_t memmove_s(void *s1, rsize_t s1max, const void *s2, rsize_t n) SIGNAL_SAFE(0); ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); + /* Overlap is explicitly allowed */ if (n > s1max) { /* do the right thing */ diff --git a/src/string/strcmp.c b/src/string/strcmp.c index 8c679f4b..58102d79 100644 --- a/src/string/strcmp.c +++ b/src/string/strcmp.c @@ -8,6 +8,7 @@ int strcmp(const char *s1, const char *s2) SIGNAL_SAFE(0); ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); + /* no modifcation, overlap is OK */ while (*s1 && *s2) { if (*s1 != *s2) { diff --git a/src/string/strcoll.c b/src/string/strcoll.c index aab2f1f5..8ad9361e 100644 --- a/src/string/strcoll.c +++ b/src/string/strcoll.c @@ -13,6 +13,7 @@ int strcoll(const char *s1, const char *s2) SIGNAL_SAFE(0); ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); + /* no modification, overlap is OK */ x1 = malloc(strxfrm(x1, s1, 0)); x2 = malloc(strxfrm(x2, s2, 0)); diff --git a/src/string/strcspn.c b/src/string/strcspn.c index 19f83fda..f2e8c588 100644 --- a/src/string/strcspn.c +++ b/src/string/strcspn.c @@ -10,6 +10,7 @@ size_t strcspn(const char *s1, const char *s2) SIGNAL_SAFE(0); ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); + /* no modification, overlap is OK */ for (i = 0; s1[i] != '\0'; i++) { if (strchr (s2, s1[i]) != NULL) { diff --git a/src/string/strncat_s.c b/src/string/strncat_s.c index 700e8fb7..99b3f0ad 100644 --- a/src/string/strncat_s.c +++ b/src/string/strncat_s.c @@ -7,7 +7,7 @@ errno_t strncat_s(char * restrict s1, rsize_t s1max, const char * restrict s2, r SIGNAL_SAFE(0); ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); - (void)s1max; //ASSERT_NOOVERLAP(s1, s1max, s2, strlen(s1) + strlen(s2)); + ASSERT_NOOVERLAP(s1, s1max, s2, n); char *append = s1 + strlen(s1); for (size_t i = 0; i < n; i++) { diff --git a/src/string/strncmp.c b/src/string/strncmp.c index bea831b3..627f9c47 100644 --- a/src/string/strncmp.c +++ b/src/string/strncmp.c @@ -8,6 +8,7 @@ int strncmp(const char *s1, const char *s2, size_t n) SIGNAL_SAFE(0); ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); + /* no modifcation, overlap is OK */ if (strlen(s1) < n) { n = strlen(s1); diff --git a/src/string/strpbrk.c b/src/string/strpbrk.c index 714c282a..7225ac4c 100644 --- a/src/string/strpbrk.c +++ b/src/string/strpbrk.c @@ -10,6 +10,7 @@ char * strpbrk(const char *s1, const char *s2) SIGNAL_SAFE(0); ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); + /* no modifcation, overlap is OK */ for (i = 0; i < strlen (s1); i++) { if (strchr(s2, s1[i]) != NULL) { diff --git a/src/string/strspn.c b/src/string/strspn.c index 156abe06..82e0dc9c 100644 --- a/src/string/strspn.c +++ b/src/string/strspn.c @@ -10,6 +10,7 @@ size_t strspn(const char *s1, const char *s2) SIGNAL_SAFE(0); ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); + /* no modification, overlap is OK */ for (i = 0; i < strlen (s1); i++) { if (strchr(s2, s1[i]) == NULL) { diff --git a/src/string/strstr.c b/src/string/strstr.c index fa5db853..eac8ea77 100644 --- a/src/string/strstr.c +++ b/src/string/strstr.c @@ -12,6 +12,7 @@ char * strstr(const char *s1, const char *s2) SIGNAL_SAFE(0); ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); + /* no modifcation, overlap is OK */ l1 = strlen(s1); l2 = strlen(s2); diff --git a/src/string/strtok.c b/src/string/strtok.c index 69b7fcc8..c46a9556 100644 --- a/src/string/strtok.c +++ b/src/string/strtok.c @@ -11,6 +11,7 @@ char * strtok(char * restrict s1, const char * restrict s2) /* TODO */ SIGNAL_SAFE(0); ASSERT_NONNULL(s2); + /* nothing is copied, overlap is OK */ /* RETURN(CONSTANT(NULL), there are no further tokens, only token separators); diff --git a/src/string/strtok_s.c b/src/string/strtok_s.c index 859e4885..867029c6 100644 --- a/src/string/strtok_s.c +++ b/src/string/strtok_s.c @@ -4,6 +4,8 @@ char * strtok_s(char * restrict s1, rsize_t * restrict s1max, const char * restrict s2, char **restrict ptr) { SIGNAL_SAFE(0); + /* TODO: check for overlap */ + /* what is the limit a pointer? */ (void)s1; (void)s1max; (void)s2; (void)ptr; return NULL; } diff --git a/src/string/strxfrm.c b/src/string/strxfrm.c index fc16087a..9d0b5429 100644 --- a/src/string/strxfrm.c +++ b/src/string/strxfrm.c @@ -9,6 +9,7 @@ size_t strxfrm(char * restrict s1, const char * restrict s2, size_t n) (void)s1; (void)s2; (void)n; SIGNAL_SAFE(0); ASSERT_NONNULL(s2); + ASSERT_NOOVERLAP(s1, n, s2, n); if (n != 0) { ASSERT_NONNULL(s1); diff --git a/src/threads/cnd_timedwait.c b/src/threads/cnd_timedwait.c index dfa13b93..1e86b7e5 100644 --- a/src/threads/cnd_timedwait.c +++ b/src/threads/cnd_timedwait.c @@ -7,6 +7,10 @@ int cnd_timedwait(cnd_t *restrict cond, mtx_t *restrict mtx, const struct timespec *restrict ts) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(cond, sizeof(*cond), mtx, sizeof(*mtx)); + ASSERT_NOOVERLAP(cond, sizeof(*cond), ts, sizeof(*ts)); + ASSERT_NOOVERLAP(mtx, sizeof(*mtx), ts, sizeof(*ts)); + switch (pthread_cond_timedwait(cond, mtx, ts)) { case 0: return thrd_success; diff --git a/src/threads/cnd_wait.c b/src/threads/cnd_wait.c index dc929573..bee8ff2b 100644 --- a/src/threads/cnd_wait.c +++ b/src/threads/cnd_wait.c @@ -6,6 +6,8 @@ int cnd_wait(cnd_t *cond, mtx_t *mtx) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(cond, sizeof(*cond), mtx, sizeof(*mtx)); + return pthread_cond_wait(cond, mtx) == 0 ? thrd_success : thrd_error; } diff --git a/src/threads/mtx_timedlock.c b/src/threads/mtx_timedlock.c index 1b073786..80069bc5 100644 --- a/src/threads/mtx_timedlock.c +++ b/src/threads/mtx_timedlock.c @@ -7,6 +7,8 @@ int mtx_timedlock(mtx_t *restrict mtx, const struct timespec *restrict ts) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(mtx, sizeof(*mtx), ts, sizeof(*ts)); + switch (pthread_mutex_timedlock(mtx, ts)) { case 0: return thrd_success; diff --git a/src/threads/thrd_create.c b/src/threads/thrd_create.c index 0b64b0c6..2e6a875f 100644 --- a/src/threads/thrd_create.c +++ b/src/threads/thrd_create.c @@ -7,6 +7,8 @@ int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) { SIGNAL_SAFE(0); + /* can't detect overlap because arg size is unknown */ + typedef void *(*pthread_start_fn)(void*); switch (pthread_create(thr, 0, (pthread_start_fn)func, arg)) { case 0: diff --git a/src/threads/thrd_sleep.c b/src/threads/thrd_sleep.c index cb8cd448..7ea445a2 100644 --- a/src/threads/thrd_sleep.c +++ b/src/threads/thrd_sleep.c @@ -6,6 +6,8 @@ int thrd_sleep(const struct timespec *duration, struct timespec *remaining) { SIGNAL_SAFE(0); + ASSERT_OVERLAP(duration, sizeof(*duration, remaining, sizeof(*remaining)); + return nanosleep(duration, remaining); } diff --git a/src/time/strftime.c b/src/time/strftime.c index 2ba09ecc..fe3017fc 100644 --- a/src/time/strftime.c +++ b/src/time/strftime.c @@ -1,6 +1,7 @@ #include <locale.h> #include <stdio.h> #include <time.h> +#include <string.h> #include "_safety.h" #include "locale/_locale.h" @@ -16,6 +17,9 @@ size_t strftime(char * restrict s, size_t maxsize, const char * restrict format, ASSERT_NONNULL(s); ASSERT_NONNULL(format); ASSERT_NONNULL(timeptr); + ASSERT_NOOVERLAP(s, maxsize, format, strlen(format)); + ASSERT_NOOVERLAP(s, maxsize, timeptr, sizeof(*timeptr)); + ASSERT_NOOVERLAP(format, sizeof(format), timeptr, sizeof(*timeptr)); #ifdef _POSIX_SOURCE tzset(); diff --git a/src/uchar/c16rtomb.c b/src/uchar/c16rtomb.c index a4e522bc..cb11c989 100644 --- a/src/uchar/c16rtomb.c +++ b/src/uchar/c16rtomb.c @@ -4,6 +4,7 @@ size_t c16rtomb(char * restrict s, char16_t c16, mbstate_t * restrict ps) { SIGNAL_SAFE(0); + /* TODO: overlap */ (void)s; (void)c16; (void)ps; diff --git a/src/uchar/c32rtomb.c b/src/uchar/c32rtomb.c index 6c0d29b8..34061679 100644 --- a/src/uchar/c32rtomb.c +++ b/src/uchar/c32rtomb.c @@ -4,6 +4,7 @@ size_t c32rtomb(char * restrict s, char32_t c32, mbstate_t * restrict ps) { SIGNAL_SAFE(0); + /* TODO: overlap */ (void)s; (void)c32; (void)ps; diff --git a/src/uchar/mbrtoc16.c b/src/uchar/mbrtoc16.c index b650841d..786880b2 100644 --- a/src/uchar/mbrtoc16.c +++ b/src/uchar/mbrtoc16.c @@ -4,6 +4,7 @@ size_t mbrtoc16(char16_t * restrict pc16, const char * restrict s, size_t n, mbstate_t * restrict ps) { SIGNAL_SAFE(0); + /* TODO: overlap */ (void)pc16; (void)s; (void)n; (void)ps; diff --git a/src/uchar/mbrtoc32.c b/src/uchar/mbrtoc32.c index af825b46..c4e4fc75 100644 --- a/src/uchar/mbrtoc32.c +++ b/src/uchar/mbrtoc32.c @@ -4,6 +4,7 @@ size_t mbrtoc32(char32_t * restrict pc32, const char * restrict s, size_t n, mbstate_t * restrict ps) { SIGNAL_SAFE(0); + /* TODO: overlap */ (void)pc32; (void)s; (void)n; (void)ps; diff --git a/src/wchar/fgetws.c b/src/wchar/fgetws.c index 5a1b71aa..1e341c18 100644 --- a/src/wchar/fgetws.c +++ b/src/wchar/fgetws.c @@ -10,6 +10,7 @@ wchar_t * fgetws(wchar_t * restrict s, int n, FILE * restrict stream) ASSERT_NONNULL(s); ASSERT_NONNULL(stream); + /* TODO: overlap */ if (fwide(stream, 1) <= 0) { /* not a wide stream */ diff --git a/src/wchar/fputws.c b/src/wchar/fputws.c index b06f73a1..4da7b13c 100644 --- a/src/wchar/fputws.c +++ b/src/wchar/fputws.c @@ -6,6 +6,7 @@ int fputws(const wchar_t * restrict s, FILE * restrict stream) { SIGNAL_SAFE(0); + /* TODO: overlap */ const wchar_t *p = s; while (*p != L'\0') { diff --git a/src/wchar/fwprintf.c b/src/wchar/fwprintf.c index f3ee6f9c..659bd3fd 100644 --- a/src/wchar/fwprintf.c +++ b/src/wchar/fwprintf.c @@ -7,6 +7,7 @@ int fwprintf(FILE * restrict stream, const wchar_t * restrict format, ...) { SIGNAL_SAFE(0); + /* TODO: overlap */ va_list ap; va_start(ap, format); diff --git a/src/wchar/fwscanf.c b/src/wchar/fwscanf.c index 46cd0b23..b691ef53 100644 --- a/src/wchar/fwscanf.c +++ b/src/wchar/fwscanf.c @@ -12,6 +12,7 @@ int fwscanf(FILE * restrict stream, const wchar_t * restrict format, ...) { SIGNAL_SAFE(0); + /* TODO: overlap */ va_list ap; va_start(ap, format); diff --git a/src/wchar/mbrlen.c b/src/wchar/mbrlen.c index 4489ad83..135a56b2 100644 --- a/src/wchar/mbrlen.c +++ b/src/wchar/mbrlen.c @@ -4,7 +4,9 @@ size_t mbrlen(const char * restrict s, size_t n, mbstate_t * restrict ps) { + SIGNAL_SAFE(0); + /* TODO: overlap */ static mbstate_t internal = 0; return mbrtowc(NULL, s, n, ps != NULL ? ps : &internal); diff --git a/src/wchar/mbrtowc.c b/src/wchar/mbrtowc.c index 56a50a11..16e2a937 100644 --- a/src/wchar/mbrtowc.c +++ b/src/wchar/mbrtowc.c @@ -5,6 +5,7 @@ size_t mbrtowc(wchar_t * restrict pwc, const char * restrict s, size_t n, mbstate_t * restrict ps) { SIGNAL_SAFE(0); + /* TODO: overlap */ (void)ps; (void)pwc; (void)n; diff --git a/src/wchar/mbsrtowcs.c b/src/wchar/mbsrtowcs.c index 2a97cc83..2f273598 100644 --- a/src/wchar/mbsrtowcs.c +++ b/src/wchar/mbsrtowcs.c @@ -5,6 +5,7 @@ size_t mbsrtowcs(wchar_t * restrict dst, const char * restrict src, size_t len, mbstate_t * restrict ps) { SIGNAL_SAFE(0); + /* TODO: overlap */ (void)dst; (void)src; (void)len; (void)ps; return 0; diff --git a/src/wchar/swprintf.c b/src/wchar/swprintf.c index 6cc546c3..30c3baf7 100644 --- a/src/wchar/swprintf.c +++ b/src/wchar/swprintf.c @@ -6,6 +6,7 @@ int swprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict format, ...) { SIGNAL_SAFE(0); + /* TODO: overlap */ va_list ap; va_start(ap, format); diff --git a/src/wchar/swscanf.c b/src/wchar/swscanf.c index 3897662c..81726bff 100644 --- a/src/wchar/swscanf.c +++ b/src/wchar/swscanf.c @@ -11,6 +11,7 @@ int swscanf(const wchar_t * restrict s, const wchar_t * restrict format, ...) { SIGNAL_SAFE(0); + /* TODO: overlap */ va_list ap; va_start(ap, format); diff --git a/src/wchar/vfwprintf.c b/src/wchar/vfwprintf.c index 89e4c6b5..9374d2be 100644 --- a/src/wchar/vfwprintf.c +++ b/src/wchar/vfwprintf.c @@ -9,6 +9,7 @@ int vfwprintf(FILE * restrict stream, const wchar_t * restrict format, va_list arg) { SIGNAL_SAFE(0); + /* TODO: overlap */ int ret = 0; struct io_options opt = {0}; diff --git a/src/wchar/vfwscanf.c b/src/wchar/vfwscanf.c index e727b0c8..617ee56d 100644 --- a/src/wchar/vfwscanf.c +++ b/src/wchar/vfwscanf.c @@ -11,6 +11,7 @@ int vfwscanf(FILE * restrict stream, const wchar_t * restrict format, va_list arg) { SIGNAL_SAFE(0); + /* TODO: overlap */ int ret = 0; struct io_options opt = {0}; diff --git a/src/wchar/vswprintf.c b/src/wchar/vswprintf.c index e9229399..022bf4c5 100644 --- a/src/wchar/vswprintf.c +++ b/src/wchar/vswprintf.c @@ -7,6 +7,7 @@ int vswprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict format, va_list arg) { SIGNAL_SAFE(0); + /* TODO: overlap */ int ret = 0; struct io_options opt = {0}; diff --git a/src/wchar/vswscanf.c b/src/wchar/vswscanf.c index c28bd64f..bd49ee3e 100644 --- a/src/wchar/vswscanf.c +++ b/src/wchar/vswscanf.c @@ -10,6 +10,7 @@ int vswscanf(const wchar_t * restrict s, const wchar_t * restrict format, va_list arg) { SIGNAL_SAFE(0); + /* TODO: overlap */ int ret = 0; struct io_options opt = {0}; diff --git a/src/wchar/wcrtomb.c b/src/wchar/wcrtomb.c index beff6457..1c48df7f 100644 --- a/src/wchar/wcrtomb.c +++ b/src/wchar/wcrtomb.c @@ -6,6 +6,7 @@ size_t wcrtomb(char * restrict s, wchar_t wc, mbstate_t * restrict ps) { SIGNAL_SAFE(0); + /* TODO: overlap */ char buf[MB_LEN_MAX+1]; if (s == NULL) { diff --git a/src/wchar/wcscat.c b/src/wchar/wcscat.c index 2674e218..798c5940 100644 --- a/src/wchar/wcscat.c +++ b/src/wchar/wcscat.c @@ -5,6 +5,7 @@ wchar_t * wcscat(wchar_t * restrict s1, const wchar_t * restrict s2) { SIGNAL_SAFE(0); + /* TODO: overlap */ wcscpy(s1 + wcslen(s1), s2); return s1; diff --git a/src/wchar/wcschr.c b/src/wchar/wcschr.c index 7fdecb89..9b050769 100644 --- a/src/wchar/wcschr.c +++ b/src/wchar/wcschr.c @@ -5,6 +5,7 @@ wchar_t * wcschr(const wchar_t * s, wchar_t c) { SIGNAL_SAFE(0); + /* TODO: overlap */ while (*s) { if (*s == c) { diff --git a/src/wchar/wcscmp.c b/src/wchar/wcscmp.c index 6693cc63..2c106f43 100644 --- a/src/wchar/wcscmp.c +++ b/src/wchar/wcscmp.c @@ -9,6 +9,7 @@ int wcscmp(const wchar_t * s1, const wchar_t * s2) ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); + /* TODO: overlap */ while (*s1 == *s2 && *s1 != L'\0') { s1++; diff --git a/src/wchar/wcscoll.c b/src/wchar/wcscoll.c index 4386b525..a057b946 100644 --- a/src/wchar/wcscoll.c +++ b/src/wchar/wcscoll.c @@ -5,6 +5,7 @@ int wcscoll(const wchar_t * s1, const wchar_t * s2) { SIGNAL_SAFE(0); + /* TODO: overlap */ /* wchar_t *collated_s1 = s1; diff --git a/src/wchar/wcscpy.c b/src/wchar/wcscpy.c index ce366198..af643326 100644 --- a/src/wchar/wcscpy.c +++ b/src/wchar/wcscpy.c @@ -5,6 +5,7 @@ wchar_t * wcscpy(wchar_t * restrict s1, const wchar_t * restrict s2) { SIGNAL_SAFE(0); + /* TODO: overlap */ return wcsncpy(s1, s2, wcslen(s2)); } diff --git a/src/wchar/wcscspn.c b/src/wchar/wcscspn.c index 5b5db5f3..178d67bf 100644 --- a/src/wchar/wcscspn.c +++ b/src/wchar/wcscspn.c @@ -11,6 +11,7 @@ size_t wcscspn(const wchar_t * s1, const wchar_t * s2) ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); + /* TODO: overlap */ for (i = 0; s1[i] != L'\0'; i++) { if (s1[i] == L'\0' || wcschr(s2, s1[i]) == NULL) { diff --git a/src/wchar/wcsftime.c b/src/wchar/wcsftime.c index e04eb966..814bc95f 100644 --- a/src/wchar/wcsftime.c +++ b/src/wchar/wcsftime.c @@ -5,6 +5,7 @@ size_t wcsftime(wchar_t * restrict s, size_t maxsize, const wchar_t * restrict format, const struct tm * restrict timeptr) { SIGNAL_SAFE(0); + /* TODO: overlap */ (void)s; (void)maxsize; (void)format; (void)timeptr; return 0; diff --git a/src/wchar/wcsncat.c b/src/wchar/wcsncat.c index 8cda3694..121fc99f 100644 --- a/src/wchar/wcsncat.c +++ b/src/wchar/wcsncat.c @@ -5,6 +5,7 @@ wchar_t * wcsncat(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n) { SIGNAL_SAFE(0); + /* TODO: overlap */ wcsncpy(s1 + wcslen(s1), s2, n); /* ensure trailing nul */ diff --git a/src/wchar/wcsncmp.c b/src/wchar/wcsncmp.c index 0caa5a9e..cf4c68a8 100644 --- a/src/wchar/wcsncmp.c +++ b/src/wchar/wcsncmp.c @@ -11,6 +11,7 @@ int wcsncmp(const wchar_t * s1, const wchar_t * s2, size_t n) ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); + /* TODO: overlap */ for (i = 0; i < n; i++) { if (s1[i] > s2[i]) { diff --git a/src/wchar/wcsncpy.c b/src/wchar/wcsncpy.c index 2c595575..40537890 100644 --- a/src/wchar/wcsncpy.c +++ b/src/wchar/wcsncpy.c @@ -5,6 +5,7 @@ wchar_t * wcsncpy(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n) { SIGNAL_SAFE(0); + /* TODO: overlap */ size_t i; int nul = 0; diff --git a/src/wchar/wcspbrk.c b/src/wchar/wcspbrk.c index fb72904c..20c25222 100644 --- a/src/wchar/wcspbrk.c +++ b/src/wchar/wcspbrk.c @@ -5,6 +5,7 @@ wchar_t * wcspbrk(const wchar_t * s1, const wchar_t * s2) { SIGNAL_SAFE(0); + /* TODO: overlap */ int i; for (i = 0; s1[i] != L'\0'; i++) { diff --git a/src/wchar/wcsrtombs.c b/src/wchar/wcsrtombs.c index 82a38ff9..9a3c6c87 100644 --- a/src/wchar/wcsrtombs.c +++ b/src/wchar/wcsrtombs.c @@ -5,6 +5,7 @@ size_t wcsrtombs(char * restrict dst, const wchar_t ** restrict src, size_t len, mbstate_t * restrict ps) { SIGNAL_SAFE(0); + /* TODO: overlap */ (void)dst; (void)src; (void)len; (void)ps; return 0; diff --git a/src/wchar/wcsspn.c b/src/wchar/wcsspn.c index ebf30980..5d1ae0df 100644 --- a/src/wchar/wcsspn.c +++ b/src/wchar/wcsspn.c @@ -5,6 +5,7 @@ size_t wcsspn(const wchar_t * s1, const wchar_t * s2) { SIGNAL_SAFE(0); + /* TODO: overlap */ size_t i; for (i = 0; s1[i] != L'\0'; i++) { diff --git a/src/wchar/wcstod.c b/src/wchar/wcstod.c index b5be3bcf..9f5b1c52 100644 --- a/src/wchar/wcstod.c +++ b/src/wchar/wcstod.c @@ -5,6 +5,7 @@ double wcstod(const wchar_t * restrict nptr, wchar_t ** restrict endptr) { SIGNAL_SAFE(0); + /* TODO: overlap */ (void)nptr; (void)endptr; return 0.0; diff --git a/src/wchar/wcstof.c b/src/wchar/wcstof.c index abea9395..c7845909 100644 --- a/src/wchar/wcstof.c +++ b/src/wchar/wcstof.c @@ -5,6 +5,7 @@ float wcstof(const wchar_t * restrict nptr, wchar_t ** restrict endptr) { SIGNAL_SAFE(0); + /* TODO: overlap */ (void)nptr; (void)endptr; return 0; diff --git a/src/wchar/wcstok.c b/src/wchar/wcstok.c index 484053d2..a9cf8d01 100644 --- a/src/wchar/wcstok.c +++ b/src/wchar/wcstok.c @@ -5,6 +5,7 @@ wchar_t * wcstok(wchar_t * restrict s1, const wchar_t * restrict s2, wchar_t ** restrict ptr) { SIGNAL_SAFE(0); + /* TODO: overlap */ (void)s1; (void)s2; (void)ptr; return s1; diff --git a/src/wchar/wcstol.c b/src/wchar/wcstol.c index 414429ac..54cbf696 100644 --- a/src/wchar/wcstol.c +++ b/src/wchar/wcstol.c @@ -10,6 +10,7 @@ long int wcstol(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) { SIGNAL_SAFE(0); + /* TODO: overlap */ long int ret = 0; long int max = LONG_MAX; diff --git a/src/wchar/wcstold.c b/src/wchar/wcstold.c index bf0304b6..a4847d40 100644 --- a/src/wchar/wcstold.c +++ b/src/wchar/wcstold.c @@ -5,6 +5,7 @@ long double wcstold(const wchar_t * restrict nptr, wchar_t ** restrict endptr) { SIGNAL_SAFE(0); + /* TODO: overlap */ (void)nptr; (void)endptr; return 0; diff --git a/src/wchar/wcstoll.c b/src/wchar/wcstoll.c index 5a86a745..1438da14 100644 --- a/src/wchar/wcstoll.c +++ b/src/wchar/wcstoll.c @@ -10,6 +10,7 @@ long long int wcstoll(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) { SIGNAL_SAFE(0); + /* TODO: overlap */ long long int ret = 0; long long int max = LLONG_MAX; diff --git a/src/wchar/wcstoul.c b/src/wchar/wcstoul.c index e7be6154..bf5771d9 100644 --- a/src/wchar/wcstoul.c +++ b/src/wchar/wcstoul.c @@ -10,6 +10,7 @@ unsigned long int wcstoul(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) { SIGNAL_SAFE(0); + /* TODO: overlap */ unsigned long int ret = 0; unsigned long int max = ULONG_MAX; diff --git a/src/wchar/wcstoull.c b/src/wchar/wcstoull.c index 26d61460..c8828d46 100644 --- a/src/wchar/wcstoull.c +++ b/src/wchar/wcstoull.c @@ -10,6 +10,7 @@ unsigned long long int wcstoull(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) { SIGNAL_SAFE(0); + /* TODO: overlap */ unsigned long long int ret = 0; unsigned long long int max = ULLONG_MAX; diff --git a/src/wchar/wcswcs.c b/src/wchar/wcswcs.c index c4541af9..07aff7d4 100644 --- a/src/wchar/wcswcs.c +++ b/src/wchar/wcswcs.c @@ -13,6 +13,7 @@ wchar_t * wcswcs(const wchar_t * s1, const wchar_t * s2) { SIGNAL_SAFE(0); + /* TODO: overlap */ return wcsstr(s1, s2); } diff --git a/src/wchar/wcsxfrm.c b/src/wchar/wcsxfrm.c index c025ee7e..ada9ff7a 100644 --- a/src/wchar/wcsxfrm.c +++ b/src/wchar/wcsxfrm.c @@ -5,6 +5,7 @@ size_t wcsxfrm(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n) { SIGNAL_SAFE(0); + /* TODO: overlap */ (void)s1; (void)s2; (void)n; return 0; diff --git a/src/wchar/wmemchr.c b/src/wchar/wmemchr.c index f6ab1f25..471b67f8 100644 --- a/src/wchar/wmemchr.c +++ b/src/wchar/wmemchr.c @@ -6,6 +6,7 @@ wchar_t * wmemchr(const wchar_t * s, wchar_t c, size_t n) { SIGNAL_SAFE(0); + /* TODO: overlap */ size_t i; diff --git a/src/wchar/wmemcmp.c b/src/wchar/wmemcmp.c index 693211d1..b607620f 100644 --- a/src/wchar/wmemcmp.c +++ b/src/wchar/wmemcmp.c @@ -5,6 +5,7 @@ int wmemcmp(const wchar_t * s1, const wchar_t * s2, size_t n) { SIGNAL_SAFE(0); + /* TODO: overlap */ size_t i; diff --git a/src/wchar/wmemcpy.c b/src/wchar/wmemcpy.c index b45912a2..5e4ee6d7 100644 --- a/src/wchar/wmemcpy.c +++ b/src/wchar/wmemcpy.c @@ -5,6 +5,7 @@ wchar_t * wmemcpy(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n) { SIGNAL_SAFE(0); + /* TODO: overlap */ size_t i; for (i = 0; i < n; i++) { diff --git a/src/wchar/wmemset.c b/src/wchar/wmemset.c index 6bf8e38b..dd9d1fc7 100644 --- a/src/wchar/wmemset.c +++ b/src/wchar/wmemset.c @@ -5,6 +5,7 @@ wchar_t * wmemset(wchar_t * s, wchar_t c, size_t n) { SIGNAL_SAFE(0); + /* TODO: overlap */ size_t i; for (i = 0; i < n; i++) { |