Skip to content

Commit

Permalink
mingw: MINGW_HAS_SECURE_API not defined on linux
Browse files Browse the repository at this point in the history
only on darwin. probe for the sinners.
fixed cross-compilation and then testing with wine.

cleanup the src headers, only safeclib_private.h is needed.
  • Loading branch information
rurban committed Sep 4, 2017
1 parent f9df87e commit de091c4
Show file tree
Hide file tree
Showing 64 changed files with 147 additions and 141 deletions.
19 changes: 12 additions & 7 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
ChangeLog file for safeclib

Changes in vxx092017 3.0.0
- Added mingw cross-compilation support and changes.
The MINGW_HAS_SECURE_API deviates in strtok_s, vsnprintf_s, wcstok_s
from C11. Add EXPORT and EXTERN decls for dllexport/dllimport.
Cleanup the src headers.
- Install bin/check_for_unsafe_apis. Renamed and improved: 7x faster,
added missing conversion hints. also install its man1.
- Seperated internal libstdunsafe target, for std but unsafe C11
functions: snprintf_s, vsnprintf_s, snwprintf_s, vsnwprintf_s, tmpnam_s
- added --enable-unsafe (the 5 funcs above are not included by default).
- Added --enable-unsafe (the 5 funcs above are not included by default).
defines SAFECLIB_ENABLE_UNSAFE
- added --disable-extensions, skipping all non-C11 safe functions.
- Added --disable-extensions, skipping all non-C11 safe functions.
This contains in summary only 11 functions for now:
memcpy_s, memmove_s, memset_s, sprintf_s, strcat_s, strcpy_s, strncat_s,
strncpy_s, strnlen_s, strtok_s, vsprintf_s.
Expand All @@ -17,15 +21,16 @@ Changes in vxx092017 3.0.0
- Macrofied many more tests
- Improved some tests for old gcc -ansi (c89) memcmp
- Add unlikely() to improve branch prediction
- added --enable-gcov and a gcov target (lcov support not yet)
- added most safe wchar and multibyte string C11 functions:
- Added --enable-gcov and a gcov target (lcov support not yet)
- Added most safe wchar and multibyte string C11 functions:
mbsrtowcs_s, mbstowcs_s, wcsrtombs_s, wcstombs_s, wcrtomb_s,
wctomb_s, wcsnlen_s, wcscpy_s, wcsncpy_s, wcscat_s, wcsncat_s,
wcstok_s, swprintf_s, vswprintf_s, wmemcpy_s, wmemmove_s.
- added --disable-wchar to disable the new multibyte and wchar functions,
wcstok_s, swprintf_s, vswprintf_s, wmemcpy_s, wmemmove_s,
wprintf_s, fwprintf_s, vfwprintf_s, vwprintf_s, vswscanf_s, swscanf_s
- Added --disable-wchar to disable the new multibyte and wchar functions,
but not the old 16/32 memory functions.
defines SAFECLIB_DISABLE_WCHAR
- better debugging support: add .i target
- Better debugging support: add .i target

Changes in v30082017 2.1.1
- Added vsprintf_s, vsnprintf_s. They are C11.
Expand Down
2 changes: 2 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ Tested Platforms
- Linux Debian 10 amd64 glibc 2.24
- Linux Void amd64 musl-1.1.16
- User Mode Linux (UML), Linux kernel version v3.5.3 w/ Debian Squeeze rootfs
- x86_64-w64-mingw32 cross-compiled and tested under wine
- i386-mingw32 cross-compiled and tested under wine


Known Issues
Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,10 @@ AC_MSG_NOTICE([Check library functions])
# ===============================================
AC_FUNC_MEMCMP
dnl no header needed as is checks if the linker can find it
dnl the last 3 deviate in mingw from c11
AC_CHECK_FUNCS([memset strcmp strcasecmp strcasestr strcspn strpbrk strspn \
strnstr strstr wmemchr wcscmp wcsstr vswprintf vsnwprintf \
memcpy_s vsnwprintf_s])
memcpy_s vsnwprintf_s strtok_s vsnprintf_s wcstok_s])
AM_CONDITIONAL([HAVE_WCSSTR], [test "x$ac_cv_func_wcsstr" = "xyes"])
AM_CONDITIONAL([HAVE_MEMCPY_S], [test "x$ac_cv_func_memcpy_s" = "xyes"])
AM_CONDITIONAL([HAVE_VSNWPRINTF_S], [test "x$ac_cv_func_vsnwprintf_s" = "xyes"])
Expand Down
6 changes: 3 additions & 3 deletions include/safe_str_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ EXTERN rsize_t
strnlen_s (const char *s, rsize_t smax);

/* string tokenizer */
#ifndef MINGW_HAS_SECURE_API
#if !(defined(_WIN32) && defined(HAVE_STRTOK_S))
/* they use:
char * strtok_s(char *_Str,const char *_Delim,char **_Context); */
EXTERN char *
Expand All @@ -115,7 +115,7 @@ EXTERN int
snprintf_s(char *restrict dest, rsize_t dmax, const char * restrict fmt, ...);

/* unsafe! use vsprintf_s instead */
#ifndef MINGW_HAS_SECURE_API
#if !(defined(_WIN32) && defined(HAVE_VSNPRINTF_S))
/* they use:
int vsnprintf_s(char *_DstBuf, size_t _DstSize, size_t _MaxCount,
const char *_Format, va_list _ArgList); */
Expand Down Expand Up @@ -371,7 +371,7 @@ EXTERN errno_t
wcsncat_s(wchar_t *restrict dest, rsize_t dmax,
const wchar_t *restrict src, rsize_t slen);

#ifndef MINGW_HAS_SECURE_API
#if !(defined(_WIN32) && defined(HAVE_WCSTOK_S))
/* they use a buggy:
wchar_t* wcstok_s(wchar_t *_Str, const wchar_t *_Delim, wchar_t **_Context); */
EXTERN wchar_t *
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ ALL_SRC_FILES =
# Not all the code can support -Werror yet so we specifically enable it
# for where it works
AM_CFLAGS += -Imem -Istr
#if !HAVE_MINGW
if !HAVE_MINGW
AM_CFLAGS += -Werror -pedantic
#endif
endif

.c.i:
$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
Expand Down
3 changes: 0 additions & 3 deletions src/extstr/strcasecmp_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"


/**
* @brief
Expand Down
3 changes: 0 additions & 3 deletions src/extstr/strcasestr_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"


/**
* @brief
Expand Down
3 changes: 0 additions & 3 deletions src/extstr/strcmp_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"


/**
* @brief
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strcmpfld_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strcpyfld_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strcpyfldin_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strcpyfldout_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
3 changes: 0 additions & 3 deletions src/extstr/strcspn_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"


/**
* @brief
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strfirstchar_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strfirstdiff_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strfirstsame_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strisalphanumeric_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strisascii_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strisdigit_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strishex_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strislowercase_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strismixedcase_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strispassword_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strisuppercase_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strlastchar_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strlastdiff_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strlastsame_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strljustify_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strnterminate_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down
3 changes: 0 additions & 3 deletions src/extstr/strpbrk_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"


/**
* @brief
Expand Down
3 changes: 0 additions & 3 deletions src/extstr/strprefix_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"


/**
* @brief
Expand Down
4 changes: 2 additions & 2 deletions src/extstr/strremovews_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*/

#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"




/**
Expand Down

0 comments on commit de091c4

Please sign in to comment.