aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-04-30 03:00:11 -0400
committerB. Watson <urchlay@slackware.uk>2024-04-30 03:00:11 -0400
commit3c4599d7202d685ab24935d1348ad9ab167fce02 (patch)
tree928461888b5b27f54bf314621538b045d9b2416c
parentca5b5bda7477386f6050c1a65802c5a68dc2de55 (diff)
downloadbw-atari8-tools-3c4599d7202d685ab24935d1348ad9ab167fce02.tar.gz
xex.c: detect short reads.
-rw-r--r--xex.c6
-rw-r--r--xexamine.c5
2 files changed, 9 insertions, 2 deletions
diff --git a/xex.c b/xex.c
index 8584286..dfdee78 100644
--- a/xex.c
+++ b/xex.c
@@ -165,18 +165,20 @@ int xex_fread_seg_data(xex_segment *seg, FILE *file) {
xex_sys_errno = errno;
if(xex_verbose) {
- fprintf(stderr, "xex_fread_seg_data(): read data:\n");
+ fprintf(stderr, "xex_fread_seg_data(): read data, len==%d, res==%d:\n", seg->len, res);
xex_print_seg_info(seg);
}
- if(res == seg->len)
+ if(res == seg->len) {
return 1;
+ }
if(ferror(file)) {
xex_errno = XERR_SYSCALL;
} else {
/* EOF or short read */
xex_errno = XERR_TRUNCATED;
+ seg->len = res;
}
return xex_check_seg(seg);
diff --git a/xexamine.c b/xexamine.c
index 3c277e5..ec1e822 100644
--- a/xexamine.c
+++ b/xexamine.c
@@ -358,6 +358,11 @@ int main(int argc, char **argv) {
while(xex_fread_seg(&seg, f)) {
segcount++;
+ xex_check_seg(&seg);
+ if(xex_errno) {
+ xex_perror(filename);
+ }
+
crc = 0;
crc32(seg.object, seg.len, &crc);