| 1 | /* arping/src/fuzz_pingip.c |
| 2 | * |
| 3 | * Copyright (C) 2016 Thomas Habets <[email protected]> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | */ |
| 19 | #define _GNU_SOURCEcxx . . $ `src/fuzz_pingip.c:19:9`! |
| 20 | |
| 21 | #include<arpa/inet.h> |
| 22 | #include<errno.h> |
| 23 | #include<inttypes.h> |
| 24 | #include<stdio.h> |
| 25 | #include<stdlib.h> |
| 26 | #include<string.h> |
| 27 | #include<time.h> |
| 28 | #include<unistd.h> |
| 29 | |
| 30 | #include<pcap.h> |
| 31 | |
| 32 | #include"arping.h"cxx . . $ `<file>/src/arping.h`/ |
| 33 | |
| 34 | int |
| 35 | maincxx . . $ main(d1b40a211a1a4e4c).() |
| 36 | { |
| 37 | const size_t maxpacket = 1500; |
| 38 | unsigned char* const packet = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, maxpacket); |
| 39 | size_t packet_size = 0; |
| 40 | |
| 41 | // Read packet. |
| 42 | { |
| 43 | unsigned char* p = packet; |
| 44 | size_t size = maxpacket; |
| 45 | while (size > 0) { |
| 46 | const ssize_tcxx . . $ ssize_t# n = readcxx . . $ read(7e34d0a36f355389).(STDIN_FILENOcxx . . $ `<external>/12628407106812493757/unistd.h:210:9`!, p, size); |
| 47 | if (n == 0) { |
| 48 | break; |
| 49 | } |
| 50 | if (n < 0) { |
| 51 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "read(): %s\n", strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 52 | return 1; |
| 53 | } |
| 54 | size -= (size_t)n; |
| 55 | p += n; |
| 56 | } |
| 57 | packet_size = (size_t)(p - packet); |
| 58 | } |
| 59 | |
| 60 | struct pcap_pkthdrcxx . . $ pcap_pkthdr# pkthdr; |
| 61 | pkthdr.tscxx . . $ pcap_pkthdr#ts..tv_seccxx . . $ timeval#tv_sec. = timecxx . . $ time(7f38134db6521d23).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 62 | pkthdr.tscxx . . $ pcap_pkthdr#ts..tv_useccxx . . $ timeval#tv_usec. = 0; |
| 63 | pkthdr.lencxx . . $ pcap_pkthdr#len. = (uint32_tcxx . . $ uint32_t#)packet_size; |
| 64 | pkthdr.caplencxx . . $ pcap_pkthdr#caplen. = (uint32_tcxx . . $ uint32_t#)packet_size; |
| 65 | |
| 66 | dstipcxx . . $ dstip. = htonlcxx . . $ `<external>/9581057695539925927/in.h:430:12`!(0x12345678); |
| 67 | pingip_recvcxx . . $ pingip_recv(b10d88091b04c79).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, &pkthdr, packet); |
| 68 | |
| 69 | freecxx . . $ free(5d22bdacc48458e8).(packet); |
| 70 | return 0; |
| 71 | } |
| 72 | /* ---- Emacs Variables ---- |
| 73 | * Local Variables: |
| 74 | * c-basic-offset: 8 |
| 75 | * indent-tabs-mode: nil |
| 76 | * End: |
| 77 | */ |