mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 11:43:31 +00:00
msvcrt: Make sure that errno is always set when calling the invalid parameter handler.
This commit is contained in:
parent
47b9dd1b55
commit
06989a0483
14 changed files with 184 additions and 322 deletions
|
@ -160,11 +160,7 @@ WCHAR** CDECL __p__wpgmptr(void) { return &MSVCRT__wpgmptr; }
|
|||
*/
|
||||
int CDECL _get_pgmptr(char** p)
|
||||
{
|
||||
if (!MSVCRT_CHECK_PMT(p))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(p)) return MSVCRT_EINVAL;
|
||||
|
||||
*p = MSVCRT__pgmptr;
|
||||
return 0;
|
||||
|
@ -175,12 +171,7 @@ int CDECL _get_pgmptr(char** p)
|
|||
*/
|
||||
int CDECL _get_wpgmptr(WCHAR** p)
|
||||
{
|
||||
if (!MSVCRT_CHECK_PMT(p))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(p)) return MSVCRT_EINVAL;
|
||||
*p = MSVCRT__wpgmptr;
|
||||
return 0;
|
||||
}
|
||||
|
@ -261,11 +252,7 @@ MSVCRT_wchar_t*** CDECL __p___winitenv(void) { return &MSVCRT___winitenv; }
|
|||
*/
|
||||
int CDECL MSVCRT__get_osplatform(int *pValue)
|
||||
{
|
||||
if (!MSVCRT_CHECK_PMT(pValue != NULL)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(pValue != NULL)) return MSVCRT_EINVAL;
|
||||
*pValue = MSVCRT__osplatform;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1655,12 +1655,9 @@ int CDECL _searchenv_s(const char* file, const char* env, char *buf, MSVCRT_size
|
|||
char*envVal, *penv;
|
||||
char curPath[MAX_PATH];
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(file != NULL) || !MSVCRT_CHECK_PMT(buf != NULL) ||
|
||||
!MSVCRT_CHECK_PMT(count > 0))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(file != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(buf != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(count > 0)) return MSVCRT_EINVAL;
|
||||
|
||||
*buf = '\0';
|
||||
|
||||
|
@ -1708,8 +1705,7 @@ int CDECL _searchenv_s(const char* file, const char* env, char *buf, MSVCRT_size
|
|||
{
|
||||
if (strlen(curPath) + 1 > count)
|
||||
{
|
||||
MSVCRT_INVALID_PMT("buf[count] is too small");
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
MSVCRT_INVALID_PMT("buf[count] is too small", MSVCRT_ERANGE);
|
||||
return MSVCRT_ERANGE;
|
||||
}
|
||||
strcpy(buf, curPath);
|
||||
|
@ -1791,12 +1787,10 @@ int CDECL _wsearchenv_s(const MSVCRT_wchar_t* file, const MSVCRT_wchar_t* env,
|
|||
MSVCRT_wchar_t* envVal, *penv;
|
||||
MSVCRT_wchar_t curPath[MAX_PATH];
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(file != NULL) || !MSVCRT_CHECK_PMT(buf != NULL) ||
|
||||
!MSVCRT_CHECK_PMT(count > 0))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(file != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(buf != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(count > 0)) return MSVCRT_EINVAL;
|
||||
|
||||
*buf = '\0';
|
||||
|
||||
/* Try CWD first */
|
||||
|
@ -1843,8 +1837,7 @@ int CDECL _wsearchenv_s(const MSVCRT_wchar_t* file, const MSVCRT_wchar_t* env,
|
|||
{
|
||||
if (strlenW(curPath) + 1 > count)
|
||||
{
|
||||
MSVCRT_INVALID_PMT("buf[count] is too small");
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
MSVCRT_INVALID_PMT("buf[count] is too small", MSVCRT_ERANGE);
|
||||
return MSVCRT_ERANGE;
|
||||
}
|
||||
strcpyW(buf, curPath);
|
||||
|
|
|
@ -170,11 +170,8 @@ int CDECL _putenv_s(const char *name, const char *value)
|
|||
|
||||
TRACE("%s %s\n", debugstr_a(name), debugstr_a(value));
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(name != NULL) || !MSVCRT_CHECK_PMT(value != NULL))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(name != NULL)) return -1;
|
||||
if (!MSVCRT_CHECK_PMT(value != NULL)) return -1;
|
||||
|
||||
ret = SetEnvironmentVariableA(name, value[0] ? value : NULL) ? 0 : -1;
|
||||
|
||||
|
@ -196,11 +193,8 @@ int CDECL _wputenv_s(const MSVCRT_wchar_t *name, const MSVCRT_wchar_t *value)
|
|||
|
||||
TRACE("%s %s\n", debugstr_w(name), debugstr_w(value));
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(name != NULL) || !MSVCRT_CHECK_PMT(value != NULL))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(name != NULL)) return -1;
|
||||
if (!MSVCRT_CHECK_PMT(value != NULL)) return -1;
|
||||
|
||||
ret = SetEnvironmentVariableW(name, value[0] ? value : NULL) ? 0 : -1;
|
||||
|
||||
|
@ -221,11 +215,11 @@ int CDECL _dupenv_s(char **buffer, MSVCRT_size_t *numberOfElements, const char *
|
|||
char* e;
|
||||
MSVCRT_size_t sz;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(buffer != NULL) || !MSVCRT_CHECK_PMT(varname) ||
|
||||
!(e = MSVCRT_getenv(varname)))
|
||||
{
|
||||
return *MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(buffer != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(varname != NULL)) return MSVCRT_EINVAL;
|
||||
|
||||
if (!(e = MSVCRT_getenv(varname))) return *MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
|
||||
sz = strlen(e) + 1;
|
||||
if (!(*buffer = MSVCRT_malloc(sz)))
|
||||
{
|
||||
|
@ -246,11 +240,11 @@ int CDECL _wdupenv_s(MSVCRT_wchar_t **buffer, MSVCRT_size_t *numberOfElements,
|
|||
MSVCRT_wchar_t* e;
|
||||
MSVCRT_size_t sz;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(buffer != NULL) || !MSVCRT_CHECK_PMT(varname) ||
|
||||
!(e = MSVCRT__wgetenv(varname)))
|
||||
{
|
||||
return *MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(buffer != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(varname != NULL)) return MSVCRT_EINVAL;
|
||||
|
||||
if (!(e = MSVCRT__wgetenv(varname))) return *MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
|
||||
sz = strlenW(e) + 1;
|
||||
if (!(*buffer = MSVCRT_malloc(sz * sizeof(MSVCRT_wchar_t))))
|
||||
{
|
||||
|
@ -269,12 +263,10 @@ int CDECL getenv_s(MSVCRT_size_t *pReturnValue, char* buffer, MSVCRT_size_t numb
|
|||
{
|
||||
char* e;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(pReturnValue != NULL) ||
|
||||
!MSVCRT_CHECK_PMT(!(buffer == NULL && numberOfElements > 0)) ||
|
||||
!MSVCRT_CHECK_PMT(varname != NULL))
|
||||
{
|
||||
return *MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(pReturnValue != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(!(buffer == NULL && numberOfElements > 0))) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(varname != NULL)) return MSVCRT_EINVAL;
|
||||
|
||||
if (!(e = MSVCRT_getenv(varname)))
|
||||
{
|
||||
*pReturnValue = 0;
|
||||
|
@ -297,12 +289,10 @@ int CDECL _wgetenv_s(MSVCRT_size_t *pReturnValue, MSVCRT_wchar_t *buffer, MSVCRT
|
|||
{
|
||||
MSVCRT_wchar_t* e;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(pReturnValue != NULL) ||
|
||||
!MSVCRT_CHECK_PMT(!(buffer == NULL && numberOfElements > 0)) ||
|
||||
!MSVCRT_CHECK_PMT(varname != NULL))
|
||||
{
|
||||
return *MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(pReturnValue != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(!(buffer == NULL && numberOfElements > 0))) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(varname != NULL)) return MSVCRT_EINVAL;
|
||||
|
||||
if (!(e = MSVCRT__wgetenv(varname)))
|
||||
{
|
||||
*pReturnValue = 0;
|
||||
|
|
|
@ -332,11 +332,9 @@ void CDECL MSVCRT_perror(const char* str)
|
|||
*/
|
||||
int CDECL _wcserror_s(MSVCRT_wchar_t* buffer, MSVCRT_size_t nc, int err)
|
||||
{
|
||||
if (!MSVCRT_CHECK_PMT(buffer != NULL) || !MSVCRT_CHECK_PMT(nc > 0))
|
||||
{
|
||||
_set_errno(MSVCRT_EINVAL);
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(buffer != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(nc > 0)) return MSVCRT_EINVAL;
|
||||
|
||||
if (err < 0 || err > MSVCRT__sys_nerr) err = MSVCRT__sys_nerr;
|
||||
MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, buffer, nc);
|
||||
return 0;
|
||||
|
@ -372,8 +370,7 @@ int CDECL __wcserror_s(MSVCRT_wchar_t* buffer, MSVCRT_size_t nc, const MSVCRT_wc
|
|||
if (str && *str) len += lstrlenW(str) + 2 /* ': ' */;
|
||||
if (len > nc)
|
||||
{
|
||||
MSVCRT_INVALID_PMT("buffer[nc] is too small");
|
||||
_set_errno(MSVCRT_ERANGE);
|
||||
MSVCRT_INVALID_PMT("buffer[nc] is too small", MSVCRT_ERANGE);
|
||||
return MSVCRT_ERANGE;
|
||||
}
|
||||
if (str && *str)
|
||||
|
|
|
@ -637,12 +637,8 @@ int CDECL MSVCRT__access(const char *filename, int mode)
|
|||
*/
|
||||
int CDECL _access_s(const char *filename, int mode)
|
||||
{
|
||||
if (!MSVCRT_CHECK_PMT(filename != NULL) ||
|
||||
!MSVCRT_CHECK_PMT((mode & ~(MSVCRT_R_OK | MSVCRT_W_OK)) == 0))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(filename != NULL)) return -1;
|
||||
if (!MSVCRT_CHECK_PMT((mode & ~(MSVCRT_R_OK | MSVCRT_W_OK)) == 0)) return -1;
|
||||
|
||||
return MSVCRT__access(filename, mode);
|
||||
}
|
||||
|
@ -674,12 +670,8 @@ int CDECL MSVCRT__waccess(const MSVCRT_wchar_t *filename, int mode)
|
|||
*/
|
||||
int CDECL _waccess_s(const MSVCRT_wchar_t *filename, int mode)
|
||||
{
|
||||
if (!MSVCRT_CHECK_PMT(filename != NULL) ||
|
||||
!MSVCRT_CHECK_PMT((mode & ~(MSVCRT_R_OK | MSVCRT_W_OK)) == 0))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(filename != NULL)) return -1;
|
||||
if (!MSVCRT_CHECK_PMT((mode & ~(MSVCRT_R_OK | MSVCRT_W_OK)) == 0)) return -1;
|
||||
|
||||
return MSVCRT__waccess(filename, mode);
|
||||
}
|
||||
|
@ -1717,12 +1709,7 @@ int CDECL MSVCRT__sopen_s( int *fd, const char *path, int oflags, int shflags, i
|
|||
TRACE("fd*: %p file: (%s) oflags: 0x%04x shflags: 0x%04x pmode: 0x%04x\n",
|
||||
fd, path, oflags, shflags, pmode);
|
||||
|
||||
if (!fd)
|
||||
{
|
||||
MSVCRT_INVALID_PMT("null out fd pointer");
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT( fd != NULL )) return MSVCRT_EINVAL;
|
||||
|
||||
*fd = -1;
|
||||
wxflag = split_oflags(oflags);
|
||||
|
@ -1836,12 +1823,7 @@ int CDECL MSVCRT__wsopen_s( int *fd, const MSVCRT_wchar_t* path, int oflags, int
|
|||
TRACE("fd*: %p :file (%s) oflags: 0x%04x shflags: 0x%04x pmode: 0x%04x\n",
|
||||
fd, debugstr_w(path), oflags, shflags, pmode);
|
||||
|
||||
if (!fd)
|
||||
{
|
||||
MSVCRT_INVALID_PMT("null out fd pointer");
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT( fd != NULL )) return MSVCRT_EINVAL;
|
||||
|
||||
*fd = -1;
|
||||
wxflag = split_oflags(oflags);
|
||||
|
@ -3049,11 +3031,9 @@ MSVCRT_FILE * CDECL MSVCRT_fopen(const char *path, const char *mode)
|
|||
int CDECL MSVCRT_fopen_s(MSVCRT_FILE** pFile,
|
||||
const char *filename, const char *mode)
|
||||
{
|
||||
if (!MSVCRT_CHECK_PMT(pFile != NULL) || !MSVCRT_CHECK_PMT(filename != NULL) ||
|
||||
!MSVCRT_CHECK_PMT(mode != NULL)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(pFile != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(filename != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mode != NULL)) return MSVCRT_EINVAL;
|
||||
|
||||
*pFile = MSVCRT_fopen(filename, mode);
|
||||
|
||||
|
@ -3076,11 +3056,9 @@ MSVCRT_FILE * CDECL MSVCRT__wfopen(const MSVCRT_wchar_t *path, const MSVCRT_wcha
|
|||
int CDECL MSVCRT__wfopen_s(MSVCRT_FILE** pFile, const MSVCRT_wchar_t *filename,
|
||||
const MSVCRT_wchar_t *mode)
|
||||
{
|
||||
if (!MSVCRT_CHECK_PMT(pFile != NULL) || !MSVCRT_CHECK_PMT(filename != NULL) ||
|
||||
!MSVCRT_CHECK_PMT(mode != NULL)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(pFile != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(filename != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mode != NULL)) return MSVCRT_EINVAL;
|
||||
|
||||
*pFile = MSVCRT__wfopen(filename, mode);
|
||||
|
||||
|
@ -3286,11 +3264,10 @@ MSVCRT_FILE* CDECL MSVCRT__wfreopen(const MSVCRT_wchar_t *path, const MSVCRT_wch
|
|||
int CDECL MSVCRT__wfreopen_s(MSVCRT_FILE** pFile,
|
||||
const MSVCRT_wchar_t *path, const MSVCRT_wchar_t *mode, MSVCRT_FILE* file)
|
||||
{
|
||||
if (!MSVCRT_CHECK_PMT(pFile != NULL) || !MSVCRT_CHECK_PMT(path != NULL) ||
|
||||
!MSVCRT_CHECK_PMT(mode != NULL) || !MSVCRT_CHECK_PMT(file != NULL)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(pFile != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(path != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mode != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(file != NULL)) return MSVCRT_EINVAL;
|
||||
|
||||
*pFile = MSVCRT__wfreopen(path, mode, file);
|
||||
|
||||
|
@ -3328,11 +3305,10 @@ MSVCRT_FILE* CDECL MSVCRT_freopen(const char *path, const char *mode, MSVCRT_FIL
|
|||
int CDECL MSVCRT_freopen_s(MSVCRT_FILE** pFile,
|
||||
const char *path, const char *mode, MSVCRT_FILE* file)
|
||||
{
|
||||
if (!MSVCRT_CHECK_PMT(pFile != NULL) || !MSVCRT_CHECK_PMT(path != NULL) ||
|
||||
!MSVCRT_CHECK_PMT(mode != NULL) || !MSVCRT_CHECK_PMT(file != NULL)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(pFile != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(path != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mode != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(file != NULL)) return MSVCRT_EINVAL;
|
||||
|
||||
*pFile = MSVCRT_freopen(path, mode, file);
|
||||
|
||||
|
@ -3797,8 +3773,7 @@ MSVCRT_FILE* CDECL MSVCRT_tmpfile(void)
|
|||
*/
|
||||
int CDECL MSVCRT_tmpfile_s(MSVCRT_FILE** file)
|
||||
{
|
||||
if (!MSVCRT_CHECK_PMT(file != NULL))
|
||||
return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(file != NULL)) return MSVCRT_EINVAL;
|
||||
|
||||
*file = MSVCRT_tmpfile();
|
||||
return 0;
|
||||
|
@ -3835,10 +3810,7 @@ int CDECL MSVCRT_vfprintf_s(MSVCRT_FILE* file, const char *format, __ms_va_list
|
|||
{
|
||||
int ret;
|
||||
|
||||
if(!MSVCRT_CHECK_PMT(file != NULL)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if(!MSVCRT_CHECK_PMT(file != NULL)) return -1;
|
||||
|
||||
MSVCRT__lock_file(file);
|
||||
ret = pf_printf_a(puts_clbk_file_a, file, format, NULL, FALSE, TRUE, arg_clbk_valist, NULL, &valist);
|
||||
|
@ -3868,10 +3840,7 @@ int CDECL MSVCRT_vfwprintf_s(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __
|
|||
{
|
||||
int ret;
|
||||
|
||||
if(!MSVCRT_CHECK_PMT( file != NULL)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT( file != NULL )) return -1;
|
||||
|
||||
MSVCRT__lock_file(file);
|
||||
ret = pf_printf_w(puts_clbk_file_w, file, format, NULL, FALSE, TRUE, arg_clbk_valist, NULL, &valist);
|
||||
|
|
|
@ -586,10 +586,9 @@ int CDECL strncpy_s(char *dest, MSVCRT_size_t numberOfElements,
|
|||
if(!count)
|
||||
return 0;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(dest != NULL) || !MSVCRT_CHECK_PMT(src != NULL) || !MSVCRT_CHECK_PMT(numberOfElements != 0)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(numberOfElements != 0)) return MSVCRT_EINVAL;
|
||||
|
||||
if(count!=MSVCRT__TRUNCATE && count<numberOfElements)
|
||||
end = count;
|
||||
|
@ -604,8 +603,7 @@ int CDECL strncpy_s(char *dest, MSVCRT_size_t numberOfElements,
|
|||
return 0;
|
||||
}
|
||||
|
||||
MSVCRT_INVALID_PMT("dest[numberOfElements] is too small");
|
||||
MSVCRT_INVALID_PMT("dest[numberOfElements] is too small", MSVCRT_EINVAL);
|
||||
dest[0] = '\0';
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
|
|
@ -1129,7 +1129,6 @@ int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask
|
|||
if (!MSVCRT_CHECK_PMT( !(newval & mask & ~all_flags) ))
|
||||
{
|
||||
if (cur) *cur = _controlfp( 0, 0 ); /* retrieve it anyway */
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
val = _controlfp( newval, mask );
|
||||
|
@ -1324,16 +1323,11 @@ int CDECL _ecvt_s( char *buffer, MSVCRT_size_t length, double number, int ndigit
|
|||
char *result;
|
||||
const char infret[] = "1#INF";
|
||||
|
||||
if(!MSVCRT_CHECK_PMT(buffer != NULL) || !MSVCRT_CHECK_PMT(decpt != NULL) || !MSVCRT_CHECK_PMT(sign != NULL))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if(!MSVCRT_CHECK_PMT(length > 2) || !MSVCRT_CHECK_PMT(ndigits < (int)length - 1))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
return MSVCRT_ERANGE;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(buffer != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(decpt != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(sign != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT_ERR( length > 2, MSVCRT_ERANGE )) return MSVCRT_ERANGE;
|
||||
if (!MSVCRT_CHECK_PMT_ERR(ndigits < (int)length - 1, MSVCRT_ERANGE )) return MSVCRT_ERANGE;
|
||||
|
||||
/* special case - inf */
|
||||
if(number == HUGE_VAL || number == -HUGE_VAL)
|
||||
|
|
|
@ -2027,10 +2027,9 @@ int CDECL MSVCRT__mbstowcs_s_l(MSVCRT_size_t *ret, MSVCRT_wchar_t *wcstr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if(!MSVCRT_CHECK_PMT(mbstr != NULL) || !MSVCRT_CHECK_PMT(wcstr != NULL)) {
|
||||
if(wcstr && size)
|
||||
wcstr[0] = '\0';
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(wcstr != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mbstr != NULL)) {
|
||||
if(size) wcstr[0] = '\0';
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2045,10 +2044,9 @@ int CDECL MSVCRT__mbstowcs_s_l(MSVCRT_size_t *ret, MSVCRT_wchar_t *wcstr,
|
|||
else if(conv==size && (count==MSVCRT__TRUNCATE || wcstr[conv-1]=='\0'))
|
||||
wcstr[conv-1] = '\0';
|
||||
else {
|
||||
MSVCRT_INVALID_PMT("wcstr[size] is too small");
|
||||
MSVCRT_INVALID_PMT("wcstr[size] is too small", MSVCRT_ERANGE);
|
||||
if(size)
|
||||
wcstr[0] = '\0';
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
return MSVCRT_ERANGE;
|
||||
}
|
||||
|
||||
|
|
|
@ -133,8 +133,8 @@ void* CDECL MSVCRT_bsearch_s(const void *key, const void *base,
|
|||
ssize_t min = 0;
|
||||
ssize_t max = nmemb - 1;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(size != 0) || !MSVCRT_CHECK_PMT(compare != NULL))
|
||||
return NULL;
|
||||
if (!MSVCRT_CHECK_PMT(size != 0)) return NULL;
|
||||
if (!MSVCRT_CHECK_PMT(compare != NULL)) return NULL;
|
||||
|
||||
while (min <= max)
|
||||
{
|
||||
|
@ -264,13 +264,10 @@ void CDECL MSVCRT_qsort_s(void *base, MSVCRT_size_t nmemb, MSVCRT_size_t size,
|
|||
void *secondarr;
|
||||
const size_t total_size = nmemb*size;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(base != NULL || (base == NULL && nmemb == 0)) ||
|
||||
!MSVCRT_CHECK_PMT(size > 0) || !MSVCRT_CHECK_PMT(compar != NULL) ||
|
||||
total_size / size != nmemb)
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(base != NULL || (base == NULL && nmemb == 0))) return;
|
||||
if (!MSVCRT_CHECK_PMT(size > 0)) return;
|
||||
if (!MSVCRT_CHECK_PMT(compar != NULL)) return;
|
||||
if (total_size / size != nmemb) return;
|
||||
|
||||
if (nmemb < 2) return;
|
||||
|
||||
|
|
|
@ -960,8 +960,9 @@ int __cdecl MSVCRT__tolower_l(int,MSVCRT__locale_t);
|
|||
* NB : MSVCRT_call_invalid_parameter_handler is a wrapper around MSVCRT__invalid_parameter in order
|
||||
* to do the Ansi to Unicode transformation
|
||||
*/
|
||||
#define MSVCRT_INVALID_PMT(x) MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0)
|
||||
#define MSVCRT_CHECK_PMT(x) ((x) || (MSVCRT_INVALID_PMT(0),FALSE))
|
||||
#define MSVCRT_INVALID_PMT(x,err) (*MSVCRT__errno() = (err), MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0))
|
||||
#define MSVCRT_CHECK_PMT_ERR(x,err) ((x) || (MSVCRT_INVALID_PMT( 0, (err) ), FALSE))
|
||||
#define MSVCRT_CHECK_PMT(x) MSVCRT_CHECK_PMT_ERR((x), MSVCRT_EINVAL)
|
||||
#endif
|
||||
|
||||
#define MSVCRT__ARGMAX 100
|
||||
|
|
|
@ -498,8 +498,7 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
|
|||
int *used;
|
||||
|
||||
if(!n_format_enabled) {
|
||||
MSVCRT_INVALID_PMT("\'n\' format specifier disabled");
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
MSVCRT_INVALID_PMT("\'n\' format specifier disabled", MSVCRT_EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -240,11 +240,9 @@ char * CDECL MSVCRT_strtok( char *str, const char *delim )
|
|||
*/
|
||||
char * CDECL MSVCRT_strtok_s(char *str, const char *delim, char **ctx)
|
||||
{
|
||||
if (!MSVCRT_CHECK_PMT(delim != NULL) || !MSVCRT_CHECK_PMT(ctx != NULL) ||
|
||||
!MSVCRT_CHECK_PMT(str != NULL || *ctx != NULL)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(delim != NULL)) return NULL;
|
||||
if (!MSVCRT_CHECK_PMT(ctx != NULL)) return NULL;
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL || *ctx != NULL)) return NULL;
|
||||
|
||||
if(!str)
|
||||
str = *ctx;
|
||||
|
@ -295,10 +293,7 @@ double CDECL MSVCRT_strtod_l( const char *str, char **end, MSVCRT__locale_t loca
|
|||
double ret;
|
||||
BOOL found_digit = FALSE;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return 0;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL)) return 0;
|
||||
|
||||
if(!locale)
|
||||
locinfo = get_locinfo();
|
||||
|
@ -682,9 +677,10 @@ int CDECL MSVCRT_strcat_s( char* dst, MSVCRT_size_t elem, const char* src )
|
|||
int CDECL MSVCRT_strncat_s( char* dst, MSVCRT_size_t elem, const char* src, MSVCRT_size_t count )
|
||||
{
|
||||
MSVCRT_size_t i, j;
|
||||
if(!MSVCRT_CHECK_PMT(dst != 0) || !MSVCRT_CHECK_PMT(elem != 0))
|
||||
return MSVCRT_EINVAL;
|
||||
if(!MSVCRT_CHECK_PMT(src != 0))
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(dst != 0)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(elem != 0)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(src != 0))
|
||||
{
|
||||
dst[0] = '\0';
|
||||
return MSVCRT_EINVAL;
|
||||
|
@ -844,10 +840,9 @@ __int64 CDECL MSVCRT_strtoi64_l(const char *nptr, char **endptr, int base, MSVCR
|
|||
|
||||
TRACE("(%s %p %d %p)\n", debugstr_a(nptr), endptr, base, locale);
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(nptr != NULL) || !MSVCRT_CHECK_PMT(base == 0 || base >= 2) ||
|
||||
!MSVCRT_CHECK_PMT(base <= 36)) {
|
||||
return 0;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(nptr != NULL)) return 0;
|
||||
if (!MSVCRT_CHECK_PMT(base == 0 || base >= 2)) return 0;
|
||||
if (!MSVCRT_CHECK_PMT(base <= 36)) return 0;
|
||||
|
||||
while(isspace(*nptr)) nptr++;
|
||||
|
||||
|
@ -924,10 +919,9 @@ unsigned __int64 CDECL MSVCRT_strtoui64_l(const char *nptr, char **endptr, int b
|
|||
|
||||
TRACE("(%s %p %d %p)\n", debugstr_a(nptr), endptr, base, locale);
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(nptr != NULL) || !MSVCRT_CHECK_PMT(base == 0 || base >= 2) ||
|
||||
!MSVCRT_CHECK_PMT(base <= 36)) {
|
||||
return 0;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(nptr != NULL)) return 0;
|
||||
if (!MSVCRT_CHECK_PMT(base == 0 || base >= 2)) return 0;
|
||||
if (!MSVCRT_CHECK_PMT(base <= 36)) return 0;
|
||||
|
||||
while(isspace(*nptr)) nptr++;
|
||||
|
||||
|
@ -997,13 +991,11 @@ int CDECL _ltoa_s(MSVCRT_long value, char *str, MSVCRT_size_t size, int radix)
|
|||
char buffer[33], *pos;
|
||||
size_t len;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
|
||||
!MSVCRT_CHECK_PMT(radix >= 2) || !MSVCRT_CHECK_PMT(radix <= 36))
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(size > 0)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(radix >= 2 && radix <= 36))
|
||||
{
|
||||
if (str && size)
|
||||
str[0] = '\0';
|
||||
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
str[0] = '\0';
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1055,8 +1047,7 @@ int CDECL _ltoa_s(MSVCRT_long value, char *str, MSVCRT_size_t size, int radix)
|
|||
*p++ = *pos--;
|
||||
|
||||
str[0] = '\0';
|
||||
MSVCRT_INVALID_PMT("str[size] is too small");
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
MSVCRT_INVALID_PMT("str[size] is too small", MSVCRT_ERANGE);
|
||||
return MSVCRT_ERANGE;
|
||||
}
|
||||
|
||||
|
@ -1075,13 +1066,11 @@ int CDECL _ltow_s(MSVCRT_long value, MSVCRT_wchar_t *str, MSVCRT_size_t size, in
|
|||
MSVCRT_wchar_t buffer[33], *pos;
|
||||
size_t len;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
|
||||
!MSVCRT_CHECK_PMT(radix >= 2) || !MSVCRT_CHECK_PMT(radix <= 36))
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(size > 0)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(radix >= 2 && radix <= 36))
|
||||
{
|
||||
if (str && size)
|
||||
str[0] = '\0';
|
||||
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
str[0] = '\0';
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1132,9 +1121,8 @@ int CDECL _ltow_s(MSVCRT_long value, MSVCRT_wchar_t *str, MSVCRT_size_t size, in
|
|||
for (pos = buffer + 31, i = 0; i < size; i++)
|
||||
*p++ = *pos--;
|
||||
|
||||
MSVCRT_INVALID_PMT("str[size] is too small");
|
||||
str[0] = '\0';
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
MSVCRT_INVALID_PMT("str[size] is too small", MSVCRT_ERANGE);
|
||||
return MSVCRT_ERANGE;
|
||||
}
|
||||
|
||||
|
@ -1167,9 +1155,11 @@ int CDECL MSVCRT__ui64toa_s(unsigned __int64 value, char *str,
|
|||
char buffer[65], *pos;
|
||||
int digit;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
|
||||
!MSVCRT_CHECK_PMT(radix>=2) || !MSVCRT_CHECK_PMT(radix<=36)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(size > 0)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(radix >= 2 && radix <= 36))
|
||||
{
|
||||
str[0] = '\0';
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1187,8 +1177,7 @@ int CDECL MSVCRT__ui64toa_s(unsigned __int64 value, char *str,
|
|||
}while(value != 0);
|
||||
|
||||
if(buffer-pos+65 > size) {
|
||||
MSVCRT_INVALID_PMT("str[size] is too small");
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
MSVCRT_INVALID_PMT("str[size] is too small", MSVCRT_EINVAL);
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1205,9 +1194,11 @@ int CDECL MSVCRT__ui64tow_s( unsigned __int64 value, MSVCRT_wchar_t *str,
|
|||
MSVCRT_wchar_t buffer[65], *pos;
|
||||
int digit;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
|
||||
!MSVCRT_CHECK_PMT(radix>=2) || !MSVCRT_CHECK_PMT(radix<=36)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(size > 0)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(radix >= 2 && radix <= 36))
|
||||
{
|
||||
str[0] = '\0';
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1224,8 +1215,7 @@ int CDECL MSVCRT__ui64tow_s( unsigned __int64 value, MSVCRT_wchar_t *str,
|
|||
} while (value != 0);
|
||||
|
||||
if(buffer-pos+65 > size) {
|
||||
MSVCRT_INVALID_PMT("str[size] is too small");
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
MSVCRT_INVALID_PMT("str[size] is too small", MSVCRT_EINVAL);
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1352,13 +1342,11 @@ int CDECL _i64toa_s(__int64 value, char *str, MSVCRT_size_t size, int radix)
|
|||
char buffer[65], *pos;
|
||||
size_t len;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
|
||||
!MSVCRT_CHECK_PMT(radix >= 2) || !MSVCRT_CHECK_PMT(radix <= 36))
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(size > 0)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(radix >= 2 && radix <= 36))
|
||||
{
|
||||
if (str && size)
|
||||
str[0] = '\0';
|
||||
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
str[0] = '\0';
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1410,8 +1398,7 @@ int CDECL _i64toa_s(__int64 value, char *str, MSVCRT_size_t size, int radix)
|
|||
*p++ = *pos--;
|
||||
|
||||
str[0] = '\0';
|
||||
MSVCRT_INVALID_PMT("str[size] is too small");
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
MSVCRT_INVALID_PMT("str[size] is too small", MSVCRT_ERANGE);
|
||||
return MSVCRT_ERANGE;
|
||||
}
|
||||
|
||||
|
@ -1430,13 +1417,11 @@ int CDECL _i64tow_s(__int64 value, MSVCRT_wchar_t *str, MSVCRT_size_t size, int
|
|||
MSVCRT_wchar_t buffer[65], *pos;
|
||||
size_t len;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
|
||||
!MSVCRT_CHECK_PMT(radix >= 2) || !MSVCRT_CHECK_PMT(radix <= 36))
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(size > 0)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(radix >= 2 && radix <= 36))
|
||||
{
|
||||
if (str && size)
|
||||
str[0] = '\0';
|
||||
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
str[0] = '\0';
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1487,9 +1472,8 @@ int CDECL _i64tow_s(__int64 value, MSVCRT_wchar_t *str, MSVCRT_size_t size, int
|
|||
for (pos = buffer + 63, i = 0; i < size; i++)
|
||||
*p++ = *pos--;
|
||||
|
||||
MSVCRT_INVALID_PMT("str[size] is too small");
|
||||
str[0] = '\0';
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
MSVCRT_INVALID_PMT("str[size] is too small", MSVCRT_ERANGE);
|
||||
return MSVCRT_ERANGE;
|
||||
}
|
||||
|
||||
|
|
|
@ -613,11 +613,7 @@ void CDECL MSVCRT__ftime64(struct MSVCRT___timeb64 *buf)
|
|||
*/
|
||||
int CDECL MSVCRT__ftime64_s(struct MSVCRT___timeb64 *buf)
|
||||
{
|
||||
if( !MSVCRT_CHECK_PMT( buf != NULL ) )
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT( buf != NULL )) return MSVCRT_EINVAL;
|
||||
MSVCRT__ftime64(buf);
|
||||
return 0;
|
||||
}
|
||||
|
@ -641,11 +637,7 @@ void CDECL MSVCRT__ftime32(struct MSVCRT___timeb32 *buf)
|
|||
*/
|
||||
int CDECL MSVCRT__ftime32_s(struct MSVCRT___timeb32 *buf)
|
||||
{
|
||||
if( !MSVCRT_CHECK_PMT( buf != NULL ) )
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT( buf != NULL )) return MSVCRT_EINVAL;
|
||||
MSVCRT__ftime32(buf);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1199,25 +1191,18 @@ char * CDECL MSVCRT_asctime(const struct MSVCRT_tm *mstm)
|
|||
*/
|
||||
int CDECL MSVCRT_asctime_s(char* time, MSVCRT_size_t size, const struct MSVCRT_tm *mstm)
|
||||
{
|
||||
if (!MSVCRT_CHECK_PMT(time != NULL)
|
||||
|| !MSVCRT_CHECK_PMT(mstm != NULL)
|
||||
|| !MSVCRT_CHECK_PMT(size >= 26)) {
|
||||
if (time && size)
|
||||
time[0] = 0;
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(mstm->tm_sec>=0) || !MSVCRT_CHECK_PMT(mstm->tm_sec<60)
|
||||
|| !MSVCRT_CHECK_PMT(mstm->tm_min>=0) || !MSVCRT_CHECK_PMT(mstm->tm_min<60)
|
||||
|| !MSVCRT_CHECK_PMT(mstm->tm_hour>=0) || !MSVCRT_CHECK_PMT(mstm->tm_hour<24)
|
||||
|| !MSVCRT_CHECK_PMT(mstm->tm_mon>=0) || !MSVCRT_CHECK_PMT(mstm->tm_mon<12)
|
||||
|| !MSVCRT_CHECK_PMT(mstm->tm_wday>=0) || !MSVCRT_CHECK_PMT(mstm->tm_wday<7)
|
||||
|| !MSVCRT_CHECK_PMT(mstm->tm_year>=0) || !MSVCRT_CHECK_PMT(mstm->tm_mday>=0)
|
||||
|| !MSVCRT_CHECK_PMT(mstm->tm_mday <= MonthLengths[IsLeapYear(1900+mstm->tm_year)][mstm->tm_mon])) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(time != NULL)) return MSVCRT_EINVAL;
|
||||
if (size) time[0] = 0;
|
||||
if (!MSVCRT_CHECK_PMT(size >= 26)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mstm != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mstm->tm_sec >= 0 && mstm->tm_sec < 60)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mstm->tm_min >= 0 && mstm->tm_min < 60)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mstm->tm_hour >= 0 && mstm->tm_hour < 24)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mstm->tm_mon >= 0 && mstm->tm_mon < 12)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mstm->tm_wday >= 0 && mstm->tm_wday < 7)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mstm->tm_year >= 0)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mstm->tm_mday >= 0)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mstm->tm_mday <= MonthLengths[IsLeapYear(1900+mstm->tm_year)][mstm->tm_mon])) return MSVCRT_EINVAL;
|
||||
|
||||
asctime_buf(time, mstm);
|
||||
return 0;
|
||||
|
@ -1254,14 +1239,10 @@ int CDECL MSVCRT__wasctime_s(MSVCRT_wchar_t* time, MSVCRT_size_t size, const str
|
|||
char buffer[26];
|
||||
int ret;
|
||||
|
||||
if(!MSVCRT_CHECK_PMT(time != NULL)
|
||||
|| !MSVCRT_CHECK_PMT(mstm != NULL)
|
||||
|| !MSVCRT_CHECK_PMT(size >= 26)) {
|
||||
if(time && size)
|
||||
time[0] = 0;
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(time != NULL)) return MSVCRT_EINVAL;
|
||||
if (size) time[0] = 0;
|
||||
if (!MSVCRT_CHECK_PMT(size >= 26)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(mstm != NULL)) return MSVCRT_EINVAL;
|
||||
|
||||
ret = MSVCRT_asctime_s(buffer, sizeof(buffer), mstm);
|
||||
if(!ret)
|
||||
|
@ -1287,17 +1268,13 @@ char * CDECL MSVCRT__ctime64(const MSVCRT___time64_t *time)
|
|||
int CDECL MSVCRT__ctime64_s(char *res, MSVCRT_size_t len, const MSVCRT___time64_t *time)
|
||||
{
|
||||
struct MSVCRT_tm *t;
|
||||
if( !MSVCRT_CHECK_PMT( res != NULL ) || !MSVCRT_CHECK_PMT( len >= 26 ) )
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
if (!MSVCRT_CHECK_PMT( res != NULL )) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT( len >= 26 )) return MSVCRT_EINVAL;
|
||||
res[0] = '\0';
|
||||
if( !MSVCRT_CHECK_PMT( time != NULL ) || !MSVCRT_CHECK_PMT( *time > 0 ) )
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT( time != NULL )) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT( *time > 0 )) return MSVCRT_EINVAL;
|
||||
|
||||
t = MSVCRT__localtime64( time );
|
||||
strcpy( res, MSVCRT_asctime( t ) );
|
||||
return 0;
|
||||
|
@ -1320,17 +1297,13 @@ char * CDECL MSVCRT__ctime32(const MSVCRT___time32_t *time)
|
|||
int CDECL MSVCRT__ctime32_s(char *res, MSVCRT_size_t len, const MSVCRT___time32_t *time)
|
||||
{
|
||||
struct MSVCRT_tm *t;
|
||||
if( !MSVCRT_CHECK_PMT( res != NULL ) || !MSVCRT_CHECK_PMT( len >= 26 ) )
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
if (!MSVCRT_CHECK_PMT( res != NULL )) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT( len >= 26 )) return MSVCRT_EINVAL;
|
||||
res[0] = '\0';
|
||||
if( !MSVCRT_CHECK_PMT( time != NULL ) || !MSVCRT_CHECK_PMT( *time > 0 ) )
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT( time != NULL )) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT( *time > 0 )) return MSVCRT_EINVAL;
|
||||
|
||||
t = MSVCRT__localtime32( time );
|
||||
strcpy( res, MSVCRT_asctime( t ) );
|
||||
return 0;
|
||||
|
|
|
@ -204,10 +204,7 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
|
|||
double ret;
|
||||
BOOL found_digit = FALSE;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return 0;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL)) return 0;
|
||||
|
||||
if(!locale)
|
||||
locinfo = get_locinfo();
|
||||
|
@ -398,13 +395,10 @@ static int MSVCRT_wcsrtombs_s_l(MSVCRT_size_t *ret, char *mbstr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(wcstr != NULL) || !MSVCRT_CHECK_PMT(*wcstr != NULL)
|
||||
|| !MSVCRT_CHECK_PMT(mbstr != NULL)) {
|
||||
if(mbstr && size)
|
||||
mbstr[0] = '\0';
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(mbstr != NULL)) return MSVCRT_EINVAL;
|
||||
if (size) mbstr[0] = '\0';
|
||||
if (!MSVCRT_CHECK_PMT(wcstr != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(*wcstr != NULL)) return MSVCRT_EINVAL;
|
||||
|
||||
if(count==MSVCRT__TRUNCATE || size<count)
|
||||
conv = size;
|
||||
|
@ -417,10 +411,9 @@ static int MSVCRT_wcsrtombs_s_l(MSVCRT_size_t *ret, char *mbstr,
|
|||
else if(conv==size && (count==MSVCRT__TRUNCATE || mbstr[conv-1]=='\0'))
|
||||
mbstr[conv-1] = '\0';
|
||||
else {
|
||||
MSVCRT_INVALID_PMT("mbstr[size] is too small");
|
||||
MSVCRT_INVALID_PMT("mbstr[size] is too small", MSVCRT_ERANGE);
|
||||
if(size)
|
||||
mbstr[0] = '\0';
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
return MSVCRT_ERANGE;
|
||||
}
|
||||
|
||||
|
@ -572,8 +565,7 @@ int CDECL MSVCRT_vsnprintf_s_l( char *str, MSVCRT_size_t sizeOfBuffer,
|
|||
|
||||
if(ret<0 || ret==len) {
|
||||
if(count!=MSVCRT__TRUNCATE && count>sizeOfBuffer) {
|
||||
MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small");
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small", MSVCRT_ERANGE);
|
||||
memset(str, 0, sizeOfBuffer);
|
||||
} else
|
||||
str[len-1] = '\0';
|
||||
|
@ -742,8 +734,7 @@ int CDECL MSVCRT_vsnwprintf_s_l( MSVCRT_wchar_t *str, MSVCRT_size_t sizeOfBuffer
|
|||
|
||||
if(ret<0 || ret==len) {
|
||||
if(count!=MSVCRT__TRUNCATE && count>sizeOfBuffer) {
|
||||
MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small");
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small", MSVCRT_ERANGE);
|
||||
memset(str, 0, sizeOfBuffer*sizeof(MSVCRT_wchar_t));
|
||||
} else
|
||||
str[len-1] = '\0';
|
||||
|
@ -1038,12 +1029,10 @@ MSVCRT_wchar_t * CDECL wcstok_s( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *deli
|
|||
{
|
||||
MSVCRT_wchar_t *ret;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(delim != NULL) || !MSVCRT_CHECK_PMT(next_token != NULL) ||
|
||||
!MSVCRT_CHECK_PMT(str != NULL || *next_token != NULL))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(delim != NULL)) return NULL;
|
||||
if (!MSVCRT_CHECK_PMT(next_token != NULL)) return NULL;
|
||||
if (!MSVCRT_CHECK_PMT(str != NULL || *next_token != NULL)) return NULL;
|
||||
|
||||
if (!str) str = *next_token;
|
||||
|
||||
while (*str && strchrW( delim, *str )) str++;
|
||||
|
@ -1302,13 +1291,10 @@ INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem,
|
|||
MSVCRT_wchar_t dststart;
|
||||
INT ret = 0;
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(dst != NULL) || !MSVCRT_CHECK_PMT(elem > 0))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(src != NULL || count == 0))
|
||||
return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(dst != NULL)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(elem > 0)) return MSVCRT_EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(src != NULL || count == 0)) return MSVCRT_EINVAL;
|
||||
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
|
@ -1319,7 +1305,7 @@ INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem,
|
|||
}
|
||||
if (dststart == elem)
|
||||
{
|
||||
MSVCRT_INVALID_PMT("dst[elem] is not NULL terminated\n");
|
||||
MSVCRT_INVALID_PMT("dst[elem] is not NULL terminated\n", MSVCRT_EINVAL);
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1340,7 +1326,7 @@ INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem,
|
|||
dst[dststart+srclen] = '\0';
|
||||
return ret;
|
||||
}
|
||||
MSVCRT_INVALID_PMT("dst[elem] is too small");
|
||||
MSVCRT_INVALID_PMT("dst[elem] is too small", MSVCRT_ERANGE);
|
||||
dst[0] = '\0';
|
||||
return MSVCRT_ERANGE;
|
||||
}
|
||||
|
@ -1358,11 +1344,9 @@ __int64 CDECL MSVCRT__wcstoi64_l(const MSVCRT_wchar_t *nptr,
|
|||
|
||||
TRACE("(%s %p %d %p)\n", debugstr_w(nptr), endptr, base, locale);
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(nptr != NULL) || !MSVCRT_CHECK_PMT(base == 0 || base >= 2) ||
|
||||
!MSVCRT_CHECK_PMT(base <= 36)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return 0;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(nptr != NULL)) return 0;
|
||||
if (!MSVCRT_CHECK_PMT(base == 0 || base >= 2)) return 0;
|
||||
if (!MSVCRT_CHECK_PMT(base <= 36)) return 0;
|
||||
|
||||
while(isspaceW(*nptr)) nptr++;
|
||||
|
||||
|
@ -1441,11 +1425,9 @@ unsigned __int64 CDECL MSVCRT__wcstoui64_l(const MSVCRT_wchar_t *nptr,
|
|||
|
||||
TRACE("(%s %p %d %p)\n", debugstr_w(nptr), endptr, base, locale);
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(nptr != NULL) || !MSVCRT_CHECK_PMT(base == 0 || base >= 2) ||
|
||||
!MSVCRT_CHECK_PMT(base <= 36)) {
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return 0;
|
||||
}
|
||||
if (!MSVCRT_CHECK_PMT(nptr != NULL)) return 0;
|
||||
if (!MSVCRT_CHECK_PMT(base == 0 || base >= 2)) return 0;
|
||||
if (!MSVCRT_CHECK_PMT(base <= 36)) return 0;
|
||||
|
||||
while(isspaceW(*nptr)) nptr++;
|
||||
|
||||
|
|
Loading…
Reference in a new issue