Kevin Athey 6dce56b2a3 [Driver] add -lresolv for all but Android.
As there 3 intercepts that depend on libresolv, link tests in ./configure scripts may be confuse by the presence of resolv symbols (i.e. dn_expand) even with -lresolv and get a runtime error.

Android provides the functionality in libc.

https://reviews.llvm.org/D122849
https://reviews.llvm.org/D126851

Reviewed By: eugenis, MaskRay

Differential Revision: https://reviews.llvm.org/D127145
2022-06-06 15:49:42 -07:00

43 lines
1.2 KiB
C++

// RUN: %clangxx_msan -O0 %s -o %t && %run %t
#include <assert.h>
#include <resolv.h>
#include <string.h>
#include <sanitizer/msan_interface.h>
void testWrite() {
char unsigned input[] = {0xff, 0xc5, 0xf7, 0xff, 0x00, 0x00, 0xff, 0x0a, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,
0x10, 0x01, 0x05, 0x00, 0x01, 0x0a, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x00};
char output[1024];
int res = dn_expand(input, input + sizeof(input), input + 23, output,
sizeof(output));
assert(res >= 0);
__msan_check_mem_is_initialized(output, res);
}
void testWriteZeroLength() {
char unsigned input[] = {
0xff, 0xc5, 0xf7, 0xff, 0x00, 0x00, 0xff, 0x0a, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x10, 0x01, 0x05, 0x00, 0x01, 0x00,
};
char output[1024];
int res = dn_expand(input, input + sizeof(input), input + 23, output,
sizeof(output));
assert(res >= 0);
__msan_check_mem_is_initialized(output, res);
}
int main(int iArgc, const char *szArgv[]) {
testWrite();
testWriteZeroLength();
return 0;
}