aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/lanalyzer.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-05-10 20:17:31 +0000
committerGuy Harris <guy@alum.mit.edu>2011-05-10 20:17:31 +0000
commit2ca5312b6476d37ad709ca5eb688952004371fd5 (patch)
treef878efe0f48993d0a8643d3630a02b631ac152ef /wiretap/lanalyzer.c
parent025f9ee4dbac6b886052d5660cb411679a1cd1fa (diff)
file_read() can return -1; don't just blindly add it to a previous
file_read() return value. Use wtap_file_read_expected_bytes() in a number of places. svn path=/trunk/; revision=37053
Diffstat (limited to 'wiretap/lanalyzer.c')
-rw-r--r--wiretap/lanalyzer.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index 7c6279e3cb..f08e2a5767 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -143,14 +143,21 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(LE_record_type, 2, wth->fh);
- bytes_read += file_read(LE_record_length, 2, wth->fh);
- if (bytes_read != 4) {
+ if (bytes_read != 2) {
+ *err = file_error(wth->fh, err_info);
+ if (*err != 0)
+ return -1;
+ return 0;
+ }
+ wth->data_offset += 2;
+ bytes_read = file_read(LE_record_length, 2, wth->fh);
+ if (bytes_read != 2) {
*err = file_error(wth->fh, err_info);
if (*err != 0)
return -1;
return 0;
}
- wth->data_offset += 4;
+ wth->data_offset += 2;
record_type = pletohs(LE_record_type);
record_length = pletohs(LE_record_length); /* make sure to do this for while() loop */
@@ -178,8 +185,18 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
wth->data_offset += record_length;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(LE_record_type, 2, wth->fh);
- bytes_read += file_read(LE_record_length, 2, wth->fh);
- if (bytes_read != 4) {
+ if (bytes_read != 2) {
+ *err = file_error(wth->fh, err_info);
+ if (*err != 0) {
+ g_free(wth->priv);
+ return -1;
+ }
+ g_free(wth->priv);
+ return 0;
+ }
+ wth->data_offset += 2;
+ bytes_read = file_read(LE_record_length, 2, wth->fh);
+ if (bytes_read != 2) {
*err = file_error(wth->fh, err_info);
if (*err != 0) {
g_free(wth->priv);
@@ -188,7 +205,7 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
g_free(wth->priv);
return 0;
}
- wth->data_offset += 4;
+ wth->data_offset += 2;
record_type = pletohs(LE_record_type);
record_length = pletohs(LE_record_length);