aboutsummaryrefslogtreecommitdiff
path: root/src/zebra.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/zebra.c')
-rw-r--r--src/zebra.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/zebra.c b/src/zebra.c
index 1289318..a3a068f 100644
--- a/src/zebra.c
+++ b/src/zebra.c
@@ -146,6 +146,10 @@ static int get_bytes(zebraFile *z, size_t size)
} else if (z->buf_size == 0 && rv == 1) {
/* EOF and there are no bytes left. */
return 1;
+ } else if (rv == 1) {
+ /* EOF but there are bytes left. */
+ sprintf(zebra_err, "got EOF but there are still %zu bytes in the buffer!", z->buf_size);
+ return -1;
}
}
@@ -228,6 +232,7 @@ int zebra_read_next_logical_record(zebraFile *z)
uint32_t size, type, nwtx, nwseg, nwtab, nwuh;
uint32_t io, noff;
uint32_t offset;
+ int rv;
while (1) {
/* Move the next logical record to the start of the buffer. */
@@ -274,12 +279,12 @@ int zebra_read_next_logical_record(zebraFile *z)
/* Padding records. */
case 5:
case 6:
- get_bytes(z,offset+size-1);
+ if ((rv = get_bytes(z,offset+size-1))) return rv;
z->lr_size = (size + 1)*4;
continue;
/* Start or end of run. */
case 1:
- get_bytes(z,offset+size);
+ if ((rv = get_bytes(z,offset+size))) return rv;
z->lr_size = (size + 2)*4;
continue;
/* Normal records. */
@@ -292,7 +297,7 @@ int zebra_read_next_logical_record(zebraFile *z)
/* For normal records the size of the logical record is NWLR + the two
* words for the size and type. */
z->lr_size = (size + 2)*4;
- get_bytes(z,offset+size);
+ if ((rv = get_bytes(z,offset+size))) return rv;
nwtx = unpacki32(z->buf+(offset+4)*4);
nwseg = unpacki32(z->buf+(offset+5)*4);