wireshark-dev October 2010 archive
Main Archive Page > Month Archives  > wireshark-dev archives
wireshark-dev: [Wireshark-dev] Seg Fault - Creating new wiretap

[Wireshark-dev] Seg Fault - Creating new wiretap type

From: Alex Lindberg <alindber_at_nospam>
Date: Thu Oct 21 2010 - 12:03:12 GMT
To: wireshark-dev@wireshark.org

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

___________________________________________________________________________
Sent via: Wireshark-dev mailing list <wireshark-dev@wireshark.org>
Archives: http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request@wireshark.org?subject=unsubscribe