Module: wine Branch: master Commit: 046bed65d46b5b096f473b9929784d2cd2409272 URL: https://gitlab.winehq.org/wine/wine/-/commit/046bed65d46b5b096f473b9929784d2...
Author: Bartosz Kosiorek gang65@poczta.onet.pl Date: Sun Oct 23 23:31:40 2022 +0200
msvcrt: Fix error handling for strcat_s.
---
dlls/msvcrt/string.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c index ba2f4fa4357..b787061d789 100644 --- a/dlls/msvcrt/string.c +++ b/dlls/msvcrt/string.c @@ -1350,9 +1350,9 @@ int CDECL strcpy_s( char* dst, size_t elem, const char* src ) int CDECL strcat_s( char* dst, size_t elem, const char* src ) { size_t i, j; - if(!dst) return EINVAL; - if(elem == 0) return EINVAL; - if(!src) + if (!MSVCRT_CHECK_PMT(dst != 0)) return EINVAL; + if (!MSVCRT_CHECK_PMT(elem != 0)) return EINVAL; + if (!MSVCRT_CHECK_PMT(src != NULL)) { dst[0] = '\0'; return EINVAL; @@ -1369,6 +1369,7 @@ int CDECL strcat_s( char* dst, size_t elem, const char* src ) } } /* Set the first element to 0, not the first element after the skipped part */ + MSVCRT_INVALID_PMT("dst[elem] is too small", ERANGE); dst[0] = '\0'; return ERANGE; }