mirror of
https://github.com/systemd/systemd.git
synced 2026-11-06 05:17:24 +00:00
fuzz-dns-packet: use ASSERT_OK() and friends
Replace assert_se() with the typed ASSERT_* macros, so that a failing assertion logs the values involved.
This commit is contained in:
1 parent
e8fd109387
commit
6b4198d7d1
1 file changed
+4
-3
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "dns-packet.h"
|
||||
#include "fuzz.h"
|
||||
#include "tests.h"
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
|
||||
@@ -11,12 +12,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
|
||||
fuzz_setup_logging();
|
||||
|
||||
assert_se(dns_packet_new(&p, DNS_PROTOCOL_DNS, /* min_alloc_dsize= */ 0, DNS_PACKET_SIZE_MAX) >= 0);
|
||||
ASSERT_OK(dns_packet_new(&p, DNS_PROTOCOL_DNS, /* min_alloc_dsize= */ 0, DNS_PACKET_SIZE_MAX));
|
||||
p->size = 0; /* by default append starts after the header, undo that */
|
||||
assert_se(dns_packet_append_blob(p, data, size, /* start= */ NULL) >= 0);
|
||||
ASSERT_OK(dns_packet_append_blob(p, data, size, /* start= */ NULL));
|
||||
if (size < DNS_PACKET_HEADER_SIZE) {
|
||||
/* make sure we pad the packet back up to the minimum header size */
|
||||
assert_se(p->allocated >= DNS_PACKET_HEADER_SIZE);
|
||||
ASSERT_GE(p->allocated, (size_t) DNS_PACKET_HEADER_SIZE);
|
||||
memzero(DNS_PACKET_DATA(p) + size, DNS_PACKET_HEADER_SIZE - size);
|
||||
p->size = DNS_PACKET_HEADER_SIZE;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user