----- Original Message -----
From: "ury segal" <[EMAIL PROTECTED]>
To: [email protected]
Subject: Re: [tcpdump-workers] pcap_loop segfaults
Date: Sun, 19 Jun 2005 02:22:48 -0400 (EDT)
>
> Just to same you some pain, here is another
> error in your program: Look at your die()
> function:
>
> void die (_Bool onoff, char *text, ...) {
> va_list(args);
> va_start(args, text);
> vfprintf(stderr, text, args);
> va_end(args);
> fflush(stdout);
>
> if (errno && onoff)
> perror("");
> exit(1);
> }
>
>
Hmm, how come vprintf man page doesn't say anything then about setting errno?
Also, I added this to my code before the first while loop:
if (!(fopen("/asdfasdfasdf", "r"))) die (1, "this: ");
and get this:
xzziroz:/home/kspecial# ./sniff
this: No such file or directory
Also, "Also,perror will print the wrong message since it relies on errno."
errno is defined globaly since it's included from errno.h
I think you have just accomplished nothing except wasting my time
have a good day
thanks,
> Once you call fflush() or vfprintf() the value
> that was in errno when you called the function
> is GONE. errno is a global variable that may be
> changed inside vfprintf and fflush(). Also,
> perror will print the wrong message since it relies
> on errno.
>
> What you probaly need is:
>
> void die (_Bool onoff, char *text, ...) {
>
> int save_errno = errno;
>
> va_list(args);
> va_start(args, text);
> vfprintf(stderr, text, args);
> va_end(args);
> fflush(stdout);
>
> if (save_errno && onoff) {
> errno= save_errno ; // Extremly ugly
> perror("");
> }
> exit(1);
> }
>
> --- K sPecial <[EMAIL PROTECTED]> wrote:
>
> > odd, yet this yas seemed to fix it, much thanks.
> >
> > ----- Original Message -----
> > From: "alexander medvedev" <[EMAIL PROTECTED]>
> > To: [email protected]
> > Subject: Re: [tcpdump-workers] pcap_loop segfaults
> > Date: Sat, 18 Jun 2005 23:26:20 -0500 (CDT)
> >
> > > > hallo,
> > > > i didn't go into much detail but for a start:
> > > i'd make "pcap_t *pfd" global and change:
> > > > if (!(pcap_open_live(iface, snaplen, 0, -1,
> > errbuf)))
> > > to
> > > if ((pfd = pcap_open_live(iface, snaplen, 0, -1,
> > errbuf)) != NULL)
> > > > this should get you started :-)
> > > > good luck,
> > > > -alexm
> > > 23:16 18/06/2005
> > > > On Sun, 19 Jun 2005, K sPecial wrote:
> > > > > Hello, i'm attempting my first pcap capture, but
> > pcap_loop > > segfaults, and i'm not quite sure why:
> > > >
> > > > -- begin ./sniff output --
> > > >
> > > > xzziroz:/home/kspecial# ./sniff
> > > > -> successfuly listening on iterface 'eth0'
> > > > Segmentation fault
> > > > xzziroz:/home/kspecial# gdb sniff
> > > > GNU gdb 6.3-debian
> > > > Copyright 2004 Free Software Foundation, Inc.
> > > > GDB is free software, covered by the GNU General
> > Public License, and you are
> > > > welcome to change it and/or distribute copies of
> > it under certain conditions.
> > > > Type "show copying" to see the conditions.
> > > > There is absolutely no warranty for GDB. Type
> > "show warranty" for details.
> > > > This GDB was configured as "i386-linux"...Using
> > host libthread_db > > library "/lib/tls/libthread_db.so.1".
> > > >
> > > > (gdb) run
> > > > Starting program: /home/kspecial/sniff
> > > > -> successfuly listening on iterface 'eth0'
> > > >
> > > > Program received signal SIGSEGV, Segmentation
> > fault.
> > > > 0xb7fa0ab0 in pcap_loop () from
> > /usr/lib/libpcap.so.0.7
> > > > (gdb) bt
> > > > #0 0xb7fa0ab0 in pcap_loop () from
> > /usr/lib/libpcap.so.0.7
> > > > #1 0x08048a0b in main ()
> > > >
> > > > -- end ./sniff output --
> > > >
> > > > it's probably something stupid I did and just am
> > not noticing it, > > here is my code:
> > > >
> > > > http://c.tkn.se/~kspex/sniff.c
> > > >
> > > > if I notice anything wrong before getting a
> > reply, i'll let you guys know.
> > > >
> > > > thanks,
> > > >
> > > > --
> > > > _______________________________________________
> > > > Check out the latest SMS services @
> > http://www.linuxmail.org
> > > > This allows you to send and receive SMS through
> > your mailbox.
> > > > -
> > > > This is the tcpdump-workers list.
> > > > Visit https://lists.sandelman.ca/ to
> > unsubscribe.
> > > >
> > > > > > -
> > > This is the tcpdump-workers list.
> > > Visit https://lists.sandelman.ca/ to unsubscribe.
> >
> >
> > -- _______________________________________________
> > Check out the latest SMS services @
> > http://www.linuxmail.org
> > This allows you to send and receive SMS through your
> > mailbox.
> > -
> > This is the tcpdump-workers list.
> > Visit https://lists.sandelman.ca/ to unsubscribe.
> >
>
>
> --ury
> -
> This is the tcpdump-workers list.
> Visit https://lists.sandelman.ca/ to unsubscribe.
--
_______________________________________________
Check out the latest SMS services @ http://www.linuxmail.org
This allows you to send and receive SMS through your mailbox.
-
This is the tcpdump-workers list.
Visit https://lists.sandelman.ca/ to unsubscribe.