Wireshark-dev: [Wireshark-dev] Seg Fault - Creating new wiretap type
From: Alex Lindberg <alindber@xxxxxxxxx>
Date: Thu, 21 Oct 2010 05:03:12 -0700 (PDT)
I am trying to add a new filetype to wiretap to allow for the reading of my custom file type, a pure text file.  When trying to read the first line during the initial myfile_open routine, the file_gets or file_read fail with a segmentation fault. If I do my own fopen for the filename, all is good, but when using wth->fh, it fails.  I have copied the format found in other wiretap/*c files and don't see my error.

If the length of the buffer == 1, then the calls work, if the buffer length is anything greater than 1, it fails.  The same form when using a private fopen to the same file works just fine.  The SIGSEGV happens during the read command.

int myfile_open(wtap *wth, int *err, gchar **err_info _U_) {

 guchar *input_line = NULL;
 input_line = g_malloc(1000*sizeof(guchar));

 if((file_gets(input_line, 1000, wth->fh)) == NULL) {
  printf("Error on file_gets 0x%0x\n",file_error(wth->fh));
  return FALSE;
 }

As always, thanks for your help with this.
Alex Lindberg