aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/pppdump.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-10-30 09:14:36 +0000
committerGuy Harris <guy@alum.mit.edu>2004-10-30 09:14:36 +0000
commita3439d24fbc671276d8998b84726df928db6a1fb (patch)
tree1655e2a311285aec5a44706a065a0a6799b519b7 /wiretap/pppdump.c
parent212015b7ff7f4bf2e68fc98bb8ef073996ebc989 (diff)
Check for errors from all calls to "file_getc()".
If we get such an error, always call "file_error()" to get an indication of what the error was and, if it returns 0, set the error to WTAP_ERR_SHORT_READ. svn path=/trunk/; revision=12442
Diffstat (limited to 'wiretap/pppdump.c')
-rw-r--r--wiretap/pppdump.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c
index 2f2ec0ba45..dd0fe80798 100644
--- a/wiretap/pppdump.c
+++ b/wiretap/pppdump.c
@@ -381,6 +381,7 @@ process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd,
state->offset++;
switch (c) {
case EOF:
+ *err = file_error(fh);
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
@@ -531,6 +532,7 @@ collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
{
int id;
pkt_t *pkt = NULL;
+ int byte0, byte1;
int n, num_written = 0;
guint32 time_long;
guint8 time_short;
@@ -583,8 +585,21 @@ collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
/*
* Get the length of the record.
*/
- n = file_getc(fh);
- n = (n << 8) + file_getc(fh);
+ byte0 = file_getc(fh);
+ if (byte0 == EOF) {
+ *err = file_error(fh);
+ if (*err == 0)
+ *err = WTAP_ERR_SHORT_READ;
+ return FALSE;
+ }
+ byte1 = file_getc(fh);
+ if (byte1 == EOF) {
+ *err = file_error(fh);
+ if (*err == 0)
+ *err = WTAP_ERR_SHORT_READ;
+ return FALSE;
+ }
+ n = (byte0 << 8) | byte1;
state->offset += 2;
if (pkt->id_offset == 0) {
@@ -606,7 +621,12 @@ collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
g_assert(num_bytes_to_skip < n);
while (num_bytes_to_skip) {
- file_getc(fh);
+ if (file_getc(fh) == EOF) {
+ *err = file_error(fh);
+ if (*err == 0)
+ *err = WTAP_ERR_SHORT_READ;
+ return FALSE;
+ }
state->offset++;
num_bytes_to_skip--;
n--;
@@ -672,6 +692,8 @@ collate(pppdump_t* state, FILE_T fh, int *err, gchar **err_info, guint8 *pd,
}
*err = file_error(fh);
+ if (*err == 0)
+ *err = WTAP_ERR_SHORT_READ;
return FALSE;
}