aboutsummaryrefslogtreecommitdiff
path: root/src/zebra.c
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2019-08-28 13:52:32 -0500
committertlatorre <tlatorre@uchicago.edu>2019-08-28 13:52:32 -0500
commit5a40f23ce50480edd235a309aaaad078d6cc740f (patch)
tree1a712c0e32f5c197ccc87f4dd39ce1ecdbc86048 /src/zebra.c
parent8a1d843403cda4b82417167d3473f3cefdfdc463 (diff)
downloadsddm-5a40f23ce50480edd235a309aaaad078d6cc740f.tar.gz
sddm-5a40f23ce50480edd235a309aaaad078d6cc740f.tar.bz2
sddm-5a40f23ce50480edd235a309aaaad078d6cc740f.zip
fix some error handling in zebra.c
This commit updates the zebra code to properly handle all the errors from get_bytes(). I also updated fit and cat-zdab to not display the errors about the FTX banks by default unless you run them with the -v command line option.
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);