diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-03-04 00:25:35 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-03-04 00:25:35 +0000 |
commit | d54bd0bd6b3f8683031aae0cbf0107779ca40b58 (patch) | |
tree | adc8f57b4cefa88b88ce35f476f4b456779cbd4b /wiretap/pppdump.c | |
parent | 7fef8be5ec6c35a80292f0d614f23dcb839a8397 (diff) | |
download | wireshark-d54bd0bd6b3f8683031aae0cbf0107779ca40b58.tar.gz |
Check for errors in seeks, "tell"s, and "stat()"s/"fstat()"s.
For file types where we allocate private data, add "close" routines
where they were missing, to free the private data. Also fix up the code
to clean up after some errors by freeing private data where that wasn't
being done.
Get rid of unused arguments to "wtap_dump_open_finish()".
Fix indentation.
svn path=/trunk/; revision=4857
Diffstat (limited to 'wiretap/pppdump.c')
-rw-r--r-- | wiretap/pppdump.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c index 7768e42746..950c4e4e02 100644 --- a/wiretap/pppdump.c +++ b/wiretap/pppdump.c @@ -1,6 +1,6 @@ /* pppdump.c * - * $Id: pppdump.c,v 1.14 2002/03/02 20:41:07 guy Exp $ + * $Id: pppdump.c,v 1.15 2002/03/04 00:25:35 guy Exp $ * * Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu> * @@ -17,8 +17,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -195,6 +195,11 @@ pppdump_open(wtap *wth, int *err) my_file_type: + if (file_seek(wth->fh, 5, SEEK_SET) == -1) { + *err = file_error(wth->fh); + return -1; + } + state = wth->capture.generic = g_malloc(sizeof(pppdump_t)); state->timestamp = pntohl(&buffer[1]); state->tenths = 0; @@ -202,7 +207,6 @@ pppdump_open(wtap *wth, int *err) init_state(state); state->offset = 5; - file_seek(wth->fh, 5, SEEK_SET); wth->file_encap = WTAP_ENCAP_PPP_WITH_PHDR; wth->file_type = WTAP_FILE_PPPDUMP; @@ -589,10 +593,10 @@ pppdump_close(wtap *wth) } if (state->pids) { /* should always be TRUE */ - unsigned int i; - for (i = 0; i < g_ptr_array_len(state->pids); i++) { - g_free(g_ptr_array_index(state->pids, i)); - } + unsigned int i; + for (i = 0; i < g_ptr_array_len(state->pids); i++) { + g_free(g_ptr_array_index(state->pids, i)); + } g_ptr_array_free(state->pids, TRUE); } |