cfg: Added support for fopen_s and sprintf_s functions. Fixed a wrong tests.

This commit is contained in:
orbitcowboy 2016-05-18 09:31:26 +02:00
parent 303a85a930
commit 46adf180d7
3 changed files with 86 additions and 4 deletions

View File

@ -943,6 +943,26 @@
<not-uninit/>
</arg>
</function>
<!-- errno_t fopen_s(FILE *restrict *restrict streamptr,
const char *restrict filename,
const char *restrict mode); -->
<function name="fopen_s">
<use-retval/>
<noreturn>false</noreturn>
<arg nr="1">
<not-null/>
<not-uninit/>
<strz/>
</arg>
<arg nr="2">
<not-null/>
<not-uninit/>
</arg>
<arg nr="3">
<not-null/>
<not-uninit/>
</arg>
</function>
<!-- int fprintf(FILE *stream, const char *format, ...); -->
<function name="fprintf,std::fprintf">
<noreturn>false</noreturn>
@ -3996,6 +4016,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
</memory>
<resource>
<alloc init="true">fopen</alloc>
<alloc init="true">fopen_s</alloc>
<alloc init="true">tmpfile</alloc>
<dealloc>fclose</dealloc>
</resource>

View File

@ -985,6 +985,8 @@
<resource>
<alloc init="true">_wfopen</alloc>
<alloc init="true">_tfopen</alloc>
<alloc init="true">_wfopen_s</alloc>
<alloc init="true">_tfopen_s</alloc>
<dealloc>fclose</dealloc>
</resource>
<memory>
@ -1741,6 +1743,47 @@
<not-uninit/>
</arg>
</function>
<!-- int sprintf_s(char *buffer, size_t sizeOfBuffer, const char *format, ... );
int swprintf_s(wchar_t *buffer, size_t sizeOfBuffer, const wchar_t *format, ...);-->
<function name="sprintf_s,swprintf_s">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<minsize type="argvalue" arg="2"/>
</arg>
<arg nr="2">
<not-uninit/>
<valid>0:</valid>
</arg>
<formatstr/>
<arg nr="3">
<formatstr/>
<not-null/>
<not-uninit/>
</arg>
</function>
<!-- int _sprintf_s_l(char *buffer, size_t sizeOfBuffer, const char *format, locale_t locale, ... );
int _swprintf_s_l(wchar_t *buffer, size_t sizeOfBuffer, const wchar_t *format, locale_t locale, ...);-->
<function name="_sprintf_s_l,_swprintf_s_l">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<minsize type="argvalue" arg="2"/>
</arg>
<arg nr="2">
<not-uninit/>
<valid>0:</valid>
</arg>
<formatstr/>
<arg nr="3">
<formatstr/>
<not-null/>
<not-uninit/>
</arg>
<arg nr="4">
<not-uninit/>
</arg>
</function>
<!-- LONG WINAPI RegEnumKeyEx(
_In_ HKEY hKey,
_In_ DWORD dwIndex,
@ -2047,4 +2090,22 @@ HFONT CreateFont(
<not-uninit/>
</arg>
</function>
<!-- errno_t _wfopen_s(FILE** pFile, const wchar_t *filename, const wchar_t *mode); -->
<function name="_wfopen_s,_tfopen_s">
<use-retval/>
<noreturn>false</noreturn>
<arg nr="1">
<not-null/>
<not-uninit/>
<strz/>
</arg>
<arg nr="2">
<not-null/>
<not-uninit/>
</arg>
<arg nr="3">
<not-null/>
<not-uninit/>
</arg>
</function>
</def>

View File

@ -2563,7 +2563,7 @@ private:
check("void foo() {\n"
" char lineBuffer [600];\n"
" const char * const format = \"%15s%17s%17s%17s%17s\n\";\n"
" sprintf_s(lineBuffer, format, \"type\", \"sum\", \"avg\", \"min\", \"max\");\n"
" sprintf_s(lineBuffer, 600, format, \"type\", \"sum\", \"avg\", \"min\", \"max\");\n"
"}\n", false, false, Settings::Win32A);
ASSERT_EQUALS("", errout.str());
@ -2572,9 +2572,9 @@ private:
" const char format2[] = \"%15s%17s%17s%17s%17s\n\";\n"
" const char * const format3 = format1;\n"
" int i = 0;\n"
" sprintf_s(lineBuffer, format1, \"type\", \"sum\", \"avg\", \"min\", i, 0);\n"
" sprintf_s(lineBuffer, format2, \"type\", \"sum\", \"avg\", \"min\", i, 0);\n"
" sprintf_s(lineBuffer, format3, \"type\", \"sum\", \"avg\", \"min\", i, 0);\n"
" sprintf_s(lineBuffer, 100, format1, \"type\", \"sum\", \"avg\", \"min\", i, 0);\n"
" sprintf_s(lineBuffer, 100, format2, \"type\", \"sum\", \"avg\", \"min\", i, 0);\n"
" sprintf_s(lineBuffer, 100, format3, \"type\", \"sum\", \"avg\", \"min\", i, 0);\n"
" sprintf(lineBuffer, format1, \"type\", \"sum\", \"avg\", \"min\", i, 0);\n"
" sprintf(lineBuffer, format2, \"type\", \"sum\", \"avg\", \"min\", i, 0);\n"
" sprintf(lineBuffer, format3, \"type\", \"sum\", \"avg\", \"min\", i, 0);\n"