LCOV - code coverage report
Current view: top level - fuzz - fuzz-dns-packet.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 0 13 0.0 %
Date: 2019-08-23 13:36:53 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include "fuzz.h"
       4                 :            : #include "memory-util.h"
       5                 :            : #include "resolved-dns-packet.h"
       6                 :            : 
       7                 :          0 : int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
       8                 :          0 :         _cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
       9                 :            : 
      10         [ #  # ]:          0 :         if (size > DNS_PACKET_SIZE_MAX)
      11                 :          0 :                 return 0;
      12                 :            : 
      13         [ #  # ]:          0 :         assert_se(dns_packet_new(&p, DNS_PROTOCOL_DNS, 0, DNS_PACKET_SIZE_MAX) >= 0);
      14                 :          0 :         p->size = 0; /* by default append starts after the header, undo that */
      15         [ #  # ]:          0 :         assert_se(dns_packet_append_blob(p, data, size, NULL) >= 0);
      16         [ #  # ]:          0 :         if (size < DNS_PACKET_HEADER_SIZE) {
      17                 :            :                 /* make sure we pad the packet back up to the minimum header size */
      18         [ #  # ]:          0 :                 assert_se(p->allocated >= DNS_PACKET_HEADER_SIZE);
      19         [ #  # ]:          0 :                 memzero(DNS_PACKET_DATA(p) + size, DNS_PACKET_HEADER_SIZE - size);
      20                 :          0 :                 p->size = DNS_PACKET_HEADER_SIZE;
      21                 :            :         }
      22                 :          0 :         (void) dns_packet_extract(p);
      23                 :            : 
      24                 :          0 :         return 0;
      25                 :            : }

Generated by: LCOV version 1.14