Skip to content

Commit ccbc6a3

Browse files
committed
gnu.cfg: Added support for gethostbyname_r() and gethostbyname2_r()
1 parent 3576f0a commit ccbc6a3

3 files changed

Lines changed: 140 additions & 40 deletions

File tree

cfg/gnu.cfg

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,114 @@
530530
</arg>
531531
<leak-ignore/>
532532
</function>
533+
<!-- https://man7.org/linux/man-pages/man3/gethostbyaddr_r.3.html -->
534+
<!-- int gethostbyaddr_r(const void *addr, socklen_t len, int type, struct hostent *restrict ret, char *restrict buf, size_t buflen, struct hostent **restrict result, int *restrict h_errnop); -->
535+
<function name="gethostbyaddr_r">
536+
<returnValue type="int"/>
537+
<noreturn>false</noreturn>
538+
<use-retval/>
539+
<pure/>
540+
<arg nr="1" direction="in">
541+
<not-uninit/>
542+
<not-null/>
543+
</arg>
544+
<arg nr="2" direction="in">
545+
<not-uninit/>
546+
<valid>0:</valid>
547+
</arg>
548+
<arg nr="3" direction="in">
549+
<not-uninit/>
550+
</arg>
551+
<arg nr="4" direction="out">
552+
<not-null/>
553+
</arg>
554+
<arg nr="5" direction="in">
555+
<not-uninit/>
556+
<not-null/>
557+
<minsize type="argvalue" arg="6"/>
558+
</arg>
559+
<arg nr="6" direction="in">
560+
<not-uninit/>
561+
<valid>0:</valid>
562+
</arg>
563+
<arg nr="7" direction="in">
564+
<not-null/>
565+
<not-uninit/>
566+
</arg>
567+
<arg nr="8" direction="in">
568+
<not-null/>
569+
<not-uninit/>
570+
</arg>
571+
</function>
572+
<!-- https://man7.org/linux/man-pages/man3/gethostbyname2_r.3.html -->
573+
<!-- int gethostbyname2_r(const char *name, int af, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop); -->
574+
<function name="gethostbyname2_r">
575+
<returnValue type="int"/>
576+
<noreturn>false</noreturn>
577+
<use-retval/>
578+
<pure/>
579+
<arg nr="1" direction="in">
580+
<not-uninit/>
581+
<not-null/>
582+
<strz/>
583+
</arg>
584+
<arg nr="2" direction="in">
585+
<not-uninit/>
586+
</arg>
587+
<arg nr="3" direction="out">
588+
<not-null/>
589+
</arg>
590+
<arg nr="4" direction="in">
591+
<not-uninit/>
592+
<not-null/>
593+
<minsize type="argvalue" arg="5"/>
594+
</arg>
595+
<arg nr="5" direction="in">
596+
<not-uninit/>
597+
<valid>0:</valid>
598+
</arg>
599+
<arg nr="6" direction="in">
600+
<not-null/>
601+
<not-uninit/>
602+
</arg>
603+
<arg nr="7" direction="in">
604+
<not-null/>
605+
<not-uninit/>
606+
</arg>
607+
</function>
608+
<!-- https://man7.org/linux/man-pages/man3/gethostbyname_r.3.html -->
609+
<!-- int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop); -->
610+
<function name="gethostbyname_r">
611+
<returnValue type="int"/>
612+
<noreturn>false</noreturn>
613+
<use-retval/>
614+
<pure/>
615+
<arg nr="1" direction="in">
616+
<not-uninit/>
617+
<not-null/>
618+
<strz/>
619+
</arg>
620+
<arg nr="2" direction="out">
621+
<not-null/>
622+
</arg>
623+
<arg nr="3" direction="in">
624+
<not-uninit/>
625+
<not-null/>
626+
<minsize type="argvalue" arg="4"/>
627+
</arg>
628+
<arg nr="4" direction="in">
629+
<not-uninit/>
630+
<valid>0:</valid>
631+
</arg>
632+
<arg nr="5" direction="in">
633+
<not-null/>
634+
<not-uninit/>
635+
</arg>
636+
<arg nr="6" direction="in">
637+
<not-null/>
638+
<not-uninit/>
639+
</arg>
640+
</function>
533641
<!-- https://www.gnu.org/software/libc/manual/html_node/Getopt-Long-Options.html#Getopt-Long-Options -->
534642
<!-- int getopt_long(int argc, char * const argv[],
535643
const char *optstring,

cfg/posix.cfg

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3970,46 +3970,6 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
39703970
<not-bool/>
39713971
</arg>
39723972
</function>
3973-
<!-- https://man7.org/linux/man-pages/man3/gethostbyaddr_r.3.html -->
3974-
<!-- int gethostbyaddr_r(const void *addr, socklen_t len, int type, struct hostent *restrict ret, char *restrict buf, size_t buflen, struct hostent **restrict result, int *restrict h_errnop); -->
3975-
<function name="gethostbyaddr_r">
3976-
<returnValue type="int"/>
3977-
<noreturn>false</noreturn>
3978-
<use-retval/>
3979-
<pure/>
3980-
<arg nr="1" direction="in">
3981-
<not-uninit/>
3982-
<not-null/>
3983-
</arg>
3984-
<arg nr="2" direction="in">
3985-
<not-uninit/>
3986-
<valid>0:</valid>
3987-
</arg>
3988-
<arg nr="3" direction="in">
3989-
<not-uninit/>
3990-
</arg>
3991-
<arg nr="4" direction="out">
3992-
<not-null/>
3993-
</arg>
3994-
<arg nr="5" direction="in">
3995-
<not-uninit/>
3996-
<not-null/>
3997-
<minsize type="argvalue" arg="6"/>
3998-
</arg>
3999-
<arg nr="6" direction="in">
4000-
<not-uninit/>
4001-
<valid>0:</valid>
4002-
</arg>
4003-
<arg nr="7" direction="in">
4004-
<not-null/>
4005-
<not-uninit/>
4006-
</arg>
4007-
<arg nr="8" direction="in">
4008-
<not-null/>
4009-
<not-uninit/>
4010-
</arg>
4011-
</function>
4012-
40133973
<!-- void setkey(const char *key); -->
40143974
<function name="setkey">
40153975
<noreturn>false</noreturn>

test/cfg/gnu.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <strings.h>
2626
#include <error.h>
2727
#include <getopt.h>
28+
#include <netdb.h>
2829

2930
void unreachableCode_error(void) // #11197
3031
{
@@ -34,6 +35,37 @@ void unreachableCode_error(void) // #11197
3435
int i;
3536
}
3637

38+
int nullPointer_gethostbyname2_r(const char* name, int af, struct hostent* ret, char* buf, size_t buflen, struct hostent** result, int* h_errnop)
39+
{
40+
// cppcheck-suppress nullPointer
41+
(void) gethostbyname2_r(NULL, af, ret, buf, buflen, result, h_errnop);
42+
// cppcheck-suppress nullPointer
43+
(void) gethostbyname2_r(name, af, NULL, buf, buflen, result, h_errnop);
44+
// cppcheck-suppress nullPointer
45+
(void) gethostbyname2_r(name, af, ret, NULL, buflen, result, h_errnop);
46+
// cppcheck-suppress nullPointer
47+
(void) gethostbyname2_r(name, af, ret, buf, buflen, NULL, h_errnop);
48+
// cppcheck-suppress nullPointer
49+
(void) gethostbyname2_r(name, af, ret, buf, buflen, result, NULL);
50+
return gethostbyname2_r(name, af, ret, buf, buflen, result, h_errnop);
51+
}
52+
53+
int nullPointer_gethostbyname_r(const char* name, struct hostent* ret, char* buf, size_t buflen, struct hostent** result, int* h_errnop)
54+
{
55+
// cppcheck-suppress nullPointer
56+
(void) gethostbyname_r(NULL, ret, buf, buflen, result, h_errnop);
57+
// cppcheck-suppress nullPointer
58+
(void) gethostbyname_r(name, NULL, buf, buflen, result, h_errnop);
59+
// cppcheck-suppress nullPointer
60+
(void) gethostbyname_r(name, ret, NULL, buflen, result, h_errnop);
61+
// cppcheck-suppress nullPointer
62+
(void) gethostbyname_r(name, ret, buf, buflen, NULL, h_errnop);
63+
// cppcheck-suppress nullPointer
64+
(void) gethostbyname_r(name, ret, buf, buflen, result, NULL);
65+
return gethostbyname_r(name, ret, buf, buflen, result, h_errnop);
66+
}
67+
68+
3769
int nullPointer_gethostbyaddr_r(const void* addr, socklen_t len, int type, struct hostent* ret, char* buf, size_t buflen, struct hostent** result, int* h_errnop)
3870
{
3971
// cppcheck-suppress nullPointer

0 commit comments

Comments
 (0)