gnu.cfg: Further fixes, enhancements and adding argument directions.

This commit is contained in:
versat 2019-03-14 09:26:27 +01:00
parent 6eeee743d2
commit 3d02c10fde
2 changed files with 108 additions and 74 deletions

View File

@ -449,14 +449,15 @@
<noreturn>false</noreturn>
<leak-ignore/>
<pure/>
<arg nr="1">
<arg nr="1" direction="out">
<not-null/>
</arg>
<arg nr="2">
<arg nr="2" direction="out">
<not-null/>
</arg>
<arg nr="3">
<arg nr="3" direction="out">
<not-null/>
<not-bool/>
</arg>
</function>
<!-- http://linux.die.net/man/2/getresuid -->
@ -466,14 +467,15 @@
<noreturn>false</noreturn>
<leak-ignore/>
<pure/>
<arg nr="1">
<arg nr="1" direction="out">
<not-null/>
</arg>
<arg nr="2">
<arg nr="2" direction="out">
<not-null/>
</arg>
<arg nr="3">
<arg nr="3" direction="out">
<not-null/>
<not-bool/>
</arg>
</function>
<!-- http://man7.org/linux/man-pages/man2/setresuid.2.html -->
@ -481,14 +483,15 @@
<function name="setresuid">
<returnValue type="int"/>
<noreturn>false</noreturn>
<arg nr="1">
<arg nr="1" direction="in">
<not-uninit/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-uninit/>
</arg>
<arg nr="3">
<arg nr="3" direction="in">
<not-uninit/>
<not-bool/>
</arg>
<leak-ignore/>
</function>
@ -497,14 +500,15 @@
<function name="setresgid">
<returnValue type="int"/>
<noreturn>false</noreturn>
<arg nr="1">
<arg nr="1" direction="in">
<not-uninit/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-uninit/>
</arg>
<arg nr="3">
<arg nr="3" direction="in">
<not-uninit/>
<not-bool/>
</arg>
<leak-ignore/>
</function>
@ -525,9 +529,10 @@
<function name="inet_network">
<returnValue type="uint32_t"/>
<noreturn>false</noreturn>
<arg nr="1">
<arg nr="1" direction="in">
<not-uninit/>
<not-null/>
<not-bool/>
</arg>
<leak-ignore/>
</function>
@ -535,24 +540,27 @@
<function name="inet_makeaddr">
<returnValue type="struct in_addr"/>
<noreturn>false</noreturn>
<arg nr="1">
<arg nr="1" direction="in">
<not-uninit/>
<valid>0:4294967295</valid>
<!-- 0:UINT32_MAX-->
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-uninit/>
<valid>0:4294967295</valid>
<!-- 0:UINT32_MAX-->
<not-bool/>
</arg>
<leak-ignore/>
</function>
<!-- https://linux.die.net/man/3/inet_lnaof -->
<!-- uint32_t inet_lnaof (struct in_addr addr); -->
<function name="inet_lnaof">
<returnValue type="uint32_t"/>
<noreturn>false</noreturn>
<arg nr="1">
<arg nr="1" direction="in">
<not-uninit/>
<not-bool/>
</arg>
<leak-ignore/>
</function>
@ -560,8 +568,9 @@
<function name="inet_netof">
<returnValue type="uint32_t"/>
<noreturn>false</noreturn>
<arg nr="1">
<arg nr="1" direction="in">
<not-uninit/>
<not-bool/>
</arg>
<leak-ignore/>
</function>
@ -569,34 +578,38 @@
<function name="inet_pton">
<returnValue type="int"/>
<noreturn>false</noreturn>
<arg nr="1">
<arg nr="1" direction="in">
<not-uninit/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-uninit/>
<not-null/>
</arg>
<arg nr="3">
<arg nr="3" direction="out">
<not-null/>
<not-bool/>
</arg>
<leak-ignore/>
</function>
<!-- https://linux.die.net/man/3/inet_ntop -->
<!-- const char * inet_ntop (int af, const void *cp, char *buf, socklen_t len);-->
<function name="inet_ntop">
<returnValue type="char *"/>
<returnValue type="const char *"/>
<noreturn>false</noreturn>
<arg nr="1">
<arg nr="1" direction="in">
<not-uninit/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-uninit/>
<not-null/>
</arg>
<arg nr="3">
<arg nr="3" direction="out">
<not-null/>
<minsize type="argvalue" arg="4"/>
</arg>
<arg nr="4">
<arg nr="4" direction="in">
<not-uninit/>
<not-bool/>
</arg>
<leak-ignore/>
</function>
@ -606,38 +619,43 @@
<use-retval/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<arg nr="1" direction="in">
<not-null/>
<not-bool/>
</arg>
</function>
<!-- https://linux.die.net/man/3/execvpe -->
<!-- int execvpe(const char *file, char *const argv[], char *const envp[]); -->
<function name="execvpe">
<returnValue type="int"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-uninit/>
</arg>
<arg nr="3">
<arg nr="3" direction="in">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- https://linux.die.net/man/3/mkostemp -->
<!-- int mkostemp(char *template, int flags);
int mkstemps(char *template, int suffixlen);-->
<function name="mkostemp,mkstemps">
<returnValue type="int"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<arg nr="1" direction="inout">
<not-null/>
<not-uninit/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- int mkostemps(char *template, int suffixlen, int flags); -->
@ -645,15 +663,16 @@
<returnValue type="int"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<arg nr="1" direction="inout">
<not-null/>
<not-uninit/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-uninit/>
</arg>
<arg nr="3">
<arg nr="3" direction="in">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- see http://man7.org/linux/man-pages/man3/memmem.3.html -->
@ -664,21 +683,24 @@
<leak-ignore/>
<use-retval/>
<returnValue type="void *"/>
<arg nr="1">
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<minsize type="argvalue" arg="2"/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-uninit/>
<valid>0:</valid>
</arg>
<arg nr="3">
<arg nr="3" direction="in">
<not-null/>
<not-uninit/>
<minsize type="argvalue" arg="4"/>
</arg>
<arg nr="4">
<arg nr="4" direction="in">
<not-uninit/>
<valid>0:</valid>
<not-bool/>
</arg>
</function>
<!-- http://man7.org/linux/man-pages/man3/memrchr.3.html -->
@ -687,16 +709,18 @@
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="void *"/>
<arg nr="1">
<use-retval/>
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-uninit/>
<not-bool/>
<valid>0:</valid>
</arg>
<arg nr="3">
<arg nr="3" direction="in">
<not-uninit/>
<not-bool/>
<valid>0:</valid>
</arg>
@ -707,11 +731,12 @@
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="void *"/>
<arg nr="1">
<use-retval/>
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-uninit/>
<not-bool/>
<valid>0:</valid>
@ -725,8 +750,9 @@
<returnValue type="int"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<arg nr="1" direction="in">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- http://man7.org/linux/man-pages/man3/strchr.3.html -->
@ -736,13 +762,14 @@
<returnValue type="char *"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<strz/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- http://man7.org/linux/man-pages/man2/setrlimit.2.html -->
@ -752,50 +779,53 @@
<returnValue type="int"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<arg nr="1" direction="in">
<not-uninit/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-uninit/>
</arg>
<arg nr="3">
<arg nr="3" direction="in">
<not-uninit/>
</arg>
<arg nr="4"/>
<arg nr="4" direction="out">
<not-bool/>
</arg>
</function>
<!-- see https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html -->
<define name="__builtin_expect(X,Y)" value="(X)"/>
<!-- see http://kernelnewbies.org/FAQ/LikelyUnlikely -->
<define name="likely(X)" value="(X)"/>
<define name="unlikely(X)" value="(X)"/>
<podtype name="epoll_event"/>
<!-- int epoll_create(int size);
int epoll_create1(int flags); -->
<function name="epoll_create,epoll_create1">
<noreturn>false</noreturn>
<returnValue type="int"/>
<arg nr="1">
<arg nr="1" direction="in">
<not-bool/>
<not-uninit/>
</arg>
</function>
<!-- https://linux.die.net/man/2/epoll_ctl -->
<!-- int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); -->
<function name="epoll_ctl">
<returnValue type="int"/>
<noreturn>false</noreturn>
<arg nr="1">
<arg nr="1" direction="in">
<not-bool/>
<not-uninit/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-bool/>
<not-uninit/>
</arg>
<arg nr="3">
<arg nr="3" direction="in">
<not-bool/>
<not-uninit/>
</arg>
<arg nr="4">
<arg nr="4" direction="inout">
<not-uninit/>
<not-bool/>
</arg>
</function>
@ -803,20 +833,20 @@
<function name="epoll_wait">
<returnValue type="int"/>
<noreturn>false</noreturn>
<arg nr="1">
<arg nr="1" direction="in">
<not-bool/>
<not-uninit/>
</arg>
<arg nr="2">
<arg nr="2" direction="out">
<not-bool/>
<not-null/>
</arg>
<arg nr="3">
<arg nr="3" direction="in">
<not-bool/>
<not-uninit/>
<valid>1:</valid>
</arg>
<arg nr="4">
<arg nr="4" direction="in">
<not-bool/>
<not-uninit/>
</arg>
@ -825,24 +855,24 @@
<function name="epoll_pwait">
<returnValue type="int"/>
<noreturn>false</noreturn>
<arg nr="1">
<arg nr="1" direction="in">
<not-bool/>
<not-uninit/>
</arg>
<arg nr="2">
<arg nr="2" direction="out">
<not-bool/>
<not-null/>
</arg>
<arg nr="3">
<arg nr="3" direction="in">
<not-bool/>
<not-uninit/>
<valid>1:</valid>
</arg>
<arg nr="4">
<arg nr="4" direction="in">
<not-bool/>
<not-uninit/>
</arg>
<arg nr="5">
<arg nr="5" direction="in">
<not-bool/>
<not-null/>
<not-uninit/>
@ -852,8 +882,9 @@
<function name="sethostname">
<noreturn>false</noreturn>
<returnValue type="int"/>
<arg nr="1">
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<minsize type="argvalue" arg="2"/>
</arg>
<arg nr="2">
@ -868,7 +899,7 @@
<returnValue type="char *"/>
<use-retval/>
<leak-ignore/>
<arg nr="1">
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<strz/>
@ -878,16 +909,18 @@
<!-- _(string) is often defined as gettext(string) or string somewhere in projects. -->
<!-- See https://www.gnu.org/software/gettext//manual/html_node/Mark-Keywords.html -->
<define name="_(string)" value="string"/>
<!-- https://linux.die.net/man/3/dgettext -->
<!-- char * dgettext (const char *domainname, const char *msgid); -->
<function name="dgettext">
<noreturn>false</noreturn>
<returnValue type="char *"/>
<use-retval/>
<leak-ignore/>
<arg nr="1">
<arg nr="1" direction="in">
<not-uninit/>
<strz/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-null/>
<not-uninit/>
<strz/>
@ -900,15 +933,16 @@
<returnValue type="char *"/>
<use-retval/>
<leak-ignore/>
<arg nr="1">
<arg nr="1" direction="in">
<not-uninit/>
<strz/>
</arg>
<arg nr="2">
<arg nr="2" direction="in">
<not-null/>
<not-uninit/>
<strz/>
</arg>
<arg nr="3">
<arg nr="3" direction="in">
<not-uninit/>
<not-bool/>
</arg>

View File

@ -51,7 +51,7 @@ void bufferAccessOutOfBounds__builtin_memset(void)
void bufferAccessOutOfBounds()
{
char buf[2];
char buf[2] = "a";
// This is valid
sethostname(buf, 2);
// cppcheck-suppress bufferAccessOutOfBounds