Date: Sat, 6 Jan 2001 13:24:02 -0800 (PST) From: Archie Cobbs <archie@packetdesign.com> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/24116: libpcap error state not reset in pcap_compile_nopcap() Message-ID: <200101062124.f06LO2P12872@bubba.packetdesign.com> Resent-Message-ID: <200101062130.f06LU1V49526@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 24116 >Category: bin >Synopsis: libpcap error state not reset in pcap_compile_nopcap() >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Jan 06 13:30:01 PST 2001 >Closed-Date: >Last-Modified: >Originator: Archie Cobbs >Release: FreeBSD 4.2-RELEASE i386 >Organization: Packet Design, Inc. >Environment: FreeBSD -current and 4.2-REL >Description: When pcap_compile_nopcap() returns an error, subsequent compilations of valid input also (incorrectly) return an error. As a side note, there's no way to get the error string when pcap_compile_nopcap() is used because pcap_geterr() requires a pcap_t * which you don't have if you're using pcap_compile_nopcap(). So a feature request is that pcap_geterr() accept NULL as an argument and if so return the error from the most recent call to pcap_compile_nopcap(). >How-To-Repeat: Run this program: #include <stdio.h> #include <stdlib.h> #include <err.h> #include <pcap.h> #include <net/ethernet.h> static char *tests[] = { "pcaptest", "tcp dst port 80", "udp dst host 1.1.1.1 and tcp port 80", "tcp dst port 80", }; int main(int ac, char **av) { struct bpf_program bpf; int i, r; if (ac < 2) { ac = sizeof(tests) / sizeof(*tests); av = tests; } memset(&bpf, 0, sizeof(bpf)); for (i = 1; i < ac; i++) { printf("Compiling \"%s\"\n", av[i]); r = pcap_compile_nopcap(ETHER_MAX_LEN - ETHER_HDR_LEN, DLT_RAW, &bpf, av[i], 1, ~0); if (r != 0) printf("--> Failed\n"); else printf("--> OK\n"); } return (0); } The third compilation should succeed, but it fails. >Fix: I'm going to work on this one myself but wanted to record it as a PR anyway. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101062124.f06LO2P12872>