Compilation of src/XCCDF/result.c fails on some platforms
orcl-jlana opened this issue · comments
Description of Problem:
Compilation of result.c on Solaris OS failed because undefined structures:
...
openscap/openscap-1.3.7/src/XCCDF/result.c: In function 'xccdf_result_fill_sysinfo':
openscap/openscap-1.3.7/src/XCCDF/result.c:323:41: error: storage size of 'hints' isn't known
323 | struct addrinfo hints, *info, *p;
...
It is because netdb.h is include only if OS_LINUX or OS_FREEBSD is defined. But according the RFC3493 the netdb.h should be included on all UNIX systems.
Operating System & Version:
Solaris OS, but IMHO it affects all unix systems except Linux and FreeBSD-like
Steps to Reproduce:
cmake && make
Actual Results:
...
[ 57%] Building C object src/XCCDF/CMakeFiles/xccdf_object.dir/result.c.o
/builds/openscap/openscap-1.3.7/src/XCCDF/result.c: In function 'xccdf_result_fill_sysinfo':
/builds/openscap/openscap-1.3.7/src/XCCDF/result.c:323:41: error: storage size of 'hints' isn't known
323 | struct addrinfo hints, *info, *p;
| ^~~~~
/builds/openscap/openscap-1.3.7/src/XCCDF/result.c:329:42: error: 'AI_CANONNAME' undeclared (first use in this function)
329 | hints.ai_flags = AI_CANONNAME;
| ^~~~~~~~~~~~
/builds/openscap/openscap-1.3.7/src/XCCDF/result.c:329:42: note: each undeclared identifier is reported only once for each function it appears in
/builds/openscap/openscap-1.3.7/src/XCCDF/result.c:331:41: warning: implicit declaration of function 'getaddrinfo' [-Wimplicit-function-declaration]
331 | if (!(gai_res = getaddrinfo(hostname, NULL, &hints, &info))) {
| ^~~~~~~~~~~
/builds/openscap/openscap-1.3.7/src/XCCDF/result.c:332:63: error: invalid use of undefined type 'struct addrinfo'
332 | for(p = info; p != NULL; p = p->ai_next) {
| ^~
/builds/openscap/openscap-1.3.7/src/XCCDF/result.c:333:47: error: invalid use of undefined type 'struct addrinfo'
333 | if (!p->ai_canonname)
| ^~
/builds/openscap/openscap-1.3.7/src/XCCDF/result.c:337:77: error: invalid use of undefined type 'struct addrinfo'
337 | xccdf_target_fact_set_string(fact, p->ai_canonname);
| ^~
/builds/openscap/openscap-1.3.7/src/XCCDF/result.c:341:64: error: invalid use of undefined type 'struct addrinfo'
341 | fqdn = strdup(p->ai_canonname);
| ^~
/builds/openscap/openscap-1.3.7/src/XCCDF/result.c:343:33: warning: implicit declaration of function 'freeaddrinfo' [-Wimplicit-function-declaration]
343 | freeaddrinfo(info);
| ^~~~~~~~~~~~
...