aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/radcom.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-09-28 21:35:12 -0700
committerGuy Harris <guy@alum.mit.edu>2016-09-29 04:35:48 +0000
commite91af83c637adaa7a9837de65f50596a32b08db0 (patch)
tree0c18941d92ae6ec9274f9035dfc26ed369e11572 /wiretap/radcom.c
parent48b641576c53e9c7cef2e9487669460a975a0c0d (diff)
Replace some seeks forward with wtap_read_bytes() with a null buffer pointer.
If the seek forward is just skipping record content that's not (currently) interesting, use wtap_read_bytes() with a null buffer pointer; it catches short "reads" and requires less seeking, so it may work better when reading from a pipe. Change-Id: Ifb07d20e0391a8ed97da85149d971b4e9ef093a8 Reviewed-on: https://code.wireshark.org/review/17976 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/radcom.c')
-rw-r--r--wiretap/radcom.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/wiretap/radcom.c b/wiretap/radcom.c
index e7fc81946b..f86b1f3e23 100644
--- a/wiretap/radcom.c
+++ b/wiretap/radcom.c
@@ -144,8 +144,13 @@ wtap_open_return_val radcom_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_NOT_MINE;
}
- if (file_seek(wth->fh, sizeof(struct frame_date), SEEK_CUR, err) == -1)
- return WTAP_OPEN_ERROR;
+ /* So what time is this? */
+ if (!wtap_read_bytes(wth->fh, NULL, sizeof(struct frame_date),
+ err, err_info)) {
+ if (*err != WTAP_ERR_SHORT_READ)
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
+ }
for (;;) {
if (!wtap_read_bytes(wth->fh, search_encap, 4,
@@ -167,8 +172,11 @@ wtap_open_return_val radcom_open(wtap *wth, int *err, gchar **err_info)
if (file_seek(wth->fh, -3, SEEK_CUR, err) == -1)
return WTAP_OPEN_ERROR;
}
- if (file_seek(wth->fh, 12, SEEK_CUR, err) == -1)
- return WTAP_OPEN_ERROR;
+ if (!wtap_read_bytes(wth->fh, NULL, 12, err, err_info)) {
+ if (*err != WTAP_ERR_SHORT_READ)
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
+ }
if (!wtap_read_bytes(wth->fh, search_encap, 4, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
return WTAP_OPEN_ERROR;
@@ -220,13 +228,13 @@ wtap_open_return_val radcom_open(wtap *wth, int *err, gchar **err_info)
#endif
if (wth->file_encap == WTAP_ENCAP_ETHERNET) {
- if (file_seek(wth->fh, 294, SEEK_CUR, err) == -1)
+ if (!wtap_read_bytes(wth->fh, NULL, 294, err, err_info))
return WTAP_OPEN_ERROR;
} else if (wth->file_encap == WTAP_ENCAP_LAPB) {
- if (file_seek(wth->fh, 297, SEEK_CUR, err) == -1)
+ if (!wtap_read_bytes(wth->fh, NULL, 297, err, err_info))
return WTAP_OPEN_ERROR;
} else if (wth->file_encap == WTAP_ENCAP_ATM_RFC1483) {
- if (file_seek(wth->fh, 504, SEEK_CUR, err) == -1)
+ if (!wtap_read_bytes(wth->fh, NULL, 504, err, err_info))
return WTAP_OPEN_ERROR;
}