posix.cfg,gnu.cfg: Add (get|set)hostname functions. (#1315)
Reference for POSIX gethostname: http://pubs.opengroup.org/onlinepubs/9699919799/functions/gethostname.html Reference for sethostname: http://man7.org/linux/man-pages/man2/gethostname.2.html
This commit is contained in:
parent
e46c499f5a
commit
4ef452132c
13
cfg/gnu.cfg
13
cfg/gnu.cfg
|
@ -705,6 +705,19 @@
|
||||||
<not-uninit/>
|
<not-uninit/>
|
||||||
</arg>
|
</arg>
|
||||||
</function>
|
</function>
|
||||||
|
<!-- int sethostname(const char *name, size_t len); -->
|
||||||
|
<function name="sethostname">
|
||||||
|
<noreturn>false</noreturn>
|
||||||
|
<returnValue type="int"/>
|
||||||
|
<arg nr="1">
|
||||||
|
<not-null/>
|
||||||
|
<minsize type="argvalue" arg="2"/>
|
||||||
|
</arg>
|
||||||
|
<arg nr="2">
|
||||||
|
<not-uninit/>
|
||||||
|
<valid>0:</valid>
|
||||||
|
</arg>
|
||||||
|
</function>
|
||||||
<resource>
|
<resource>
|
||||||
<dealloc>close</dealloc>
|
<dealloc>close</dealloc>
|
||||||
<alloc init="true">epoll_create</alloc>
|
<alloc init="true">epoll_create</alloc>
|
||||||
|
|
|
@ -3849,6 +3849,19 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
|
||||||
<returnValue type="void"/>
|
<returnValue type="void"/>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
</function>
|
</function>
|
||||||
|
<!-- int gethostname(char *name, size_t len); -->
|
||||||
|
<function name="gethostname">
|
||||||
|
<noreturn>false</noreturn>
|
||||||
|
<returnValue type="int"/>
|
||||||
|
<arg nr="1">
|
||||||
|
<not-null/>
|
||||||
|
<minsize type="argvalue" arg="2"/>
|
||||||
|
</arg>
|
||||||
|
<arg nr="2">
|
||||||
|
<not-uninit/>
|
||||||
|
<valid>1:</valid>
|
||||||
|
</arg>
|
||||||
|
</function>
|
||||||
<memory>
|
<memory>
|
||||||
<alloc init="true">strdup</alloc>
|
<alloc init="true">strdup</alloc>
|
||||||
<alloc init="true">strndup</alloc>
|
<alloc init="true">strndup</alloc>
|
||||||
|
|
|
@ -9,6 +9,15 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
void bufferAccessOutOfBounds()
|
||||||
|
{
|
||||||
|
char buf[2];
|
||||||
|
// This is valid
|
||||||
|
sethostname(buf, 2);
|
||||||
|
// cppcheck-suppress bufferAccessOutOfBounds
|
||||||
|
sethostname(buf, 4);
|
||||||
|
}
|
||||||
|
|
||||||
void leakReturnValNotUsed()
|
void leakReturnValNotUsed()
|
||||||
{
|
{
|
||||||
// cppcheck-suppress unreadVariable
|
// cppcheck-suppress unreadVariable
|
||||||
|
|
|
@ -48,6 +48,10 @@ void bufferAccessOutOfBounds(int fd)
|
||||||
readlinkat(1, "path", a, 5);
|
readlinkat(1, "path", a, 5);
|
||||||
// cppcheck-suppress bufferAccessOutOfBounds
|
// cppcheck-suppress bufferAccessOutOfBounds
|
||||||
readlinkat(1, "path", a, 6);
|
readlinkat(1, "path", a, 6);
|
||||||
|
// This is valid
|
||||||
|
gethostname(a, 5);
|
||||||
|
// cppcheck-suppress bufferAccessOutOfBounds
|
||||||
|
gethostname(a, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nullPointer(char *p, int fd)
|
void nullPointer(char *p, int fd)
|
||||||
|
|
Loading…
Reference in New Issue