diff options
author | Guy Harris <guy@alum.mit.edu> | 2012-12-27 12:19:25 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2012-12-27 12:19:25 +0000 |
commit | 88e9d1c1e52c95317d59a1560285a9dd8c4ce7a0 (patch) | |
tree | fa21aca9e64f751847054d3aa54557afbaef56b0 /wiretap/ascendtext.c | |
parent | 12317316aed7e871b9537431d0c10013af3547db (diff) |
Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").
When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.
For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.
svn path=/trunk/; revision=46803
Diffstat (limited to 'wiretap/ascendtext.c')
-rw-r--r-- | wiretap/ascendtext.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/wiretap/ascendtext.c b/wiretap/ascendtext.c index 1a77ea427e..cace17ed4f 100644 --- a/wiretap/ascendtext.c +++ b/wiretap/ascendtext.c @@ -148,12 +148,11 @@ static gint64 ascend_seek(wtap *wth, int *err, gchar **err_info) } } - if (byte != EOF || file_eof(wth->fh)) { - /* Either we didn't find the offset, or we got an EOF. */ + if (byte != EOF) { + /* We didn't find the offset. Treat that as a "not an Ascend file" + indication. */ *err = 0; } else { - /* We (presumably) got an error (there's no equivalent to "ferror()" - in zlib, alas, so we don't have a wrapper to check for an error). */ *err = file_error(wth->fh, err_info); } return -1; @@ -187,10 +186,9 @@ int ascend_open(wtap *wth, int *err, gchar **err_info) offset = ascend_seek(wth, err, err_info); if (offset == -1) { - if (*err == 0) - return 0; - else + if (*err != 0 && *err != WTAP_ERR_SHORT_READ) return -1; + return 0; } /* Do a trial parse of the first packet just found to see if we might really have an Ascend file */ |