Ethereal-dev: [Ethereal-dev] Segfault when reading from pipe and writing to file in 0.10.6

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Pekka Pietikainen <pp@xxxxxxxxxx>
Date: Wed, 29 Sep 2004 12:55:53 +0300
Hiya

I just noticed that if you try to input from a pipe and output to 
a file tethereal segfaults (didn't check ethereal).

The reason for this is calling pcap_snapshot(ld.pch) when ld.pch is NULL
(and pipe_fd is used instead). I kludged around it by checking for
!ld.pdh and in that case hardcoding 1500 instead, someone more familiar with
the code can probably come up with better fix :-)

Here's the offending code from tethereal.c:


    if (capture_opts.ringbuffer_on) {
      cfile.save_file_fd = ringbuf_init(cfile.save_file,
	capture_opts.ringbuffer_num_files);
	if (cfile.save_file_fd != -1) {
	ld.pdh = ringbuf_init_wtap_dump_fdopen(out_file_type, ld.linktype,
          pcap_snapshot(ld.pch), &err);
	} else {
	err = errno;	/* "ringbuf_init()" failed */
	ld.pdh = NULL;
	}
    } else {
      ld.pdh = wtap_dump_open(cfile.save_file, out_file_type,
		 ld.linktype, pcap_snapshot(ld.pch), &err);
    }