X-Git-Url: https://git.draconx.ca/gitweb/liblbx.git/blobdiff_plain/131cef630544d733d13bb493a05ff6ae523a0538..bd5f6b55320b6889827908762197642b484ea28d:/src/lbx.c?ds=sidebyside diff --git a/src/lbx.c b/src/lbx.c index 1198ebb..8080b67 100644 --- a/src/lbx.c +++ b/src/lbx.c @@ -42,7 +42,7 @@ struct lbx_priv { struct lbx_file_state *last_file; - unsigned long offsets[]; + unsigned long offsets[FLEXIBLE_ARRAY_MEMBER]; }; struct lbx_file_state { @@ -51,7 +51,7 @@ struct lbx_file_state { int eof; }; -static struct lbx_priv *lbx_init(unsigned char hdr[static LBX_HDR_SIZE]) +static struct lbx_priv *lbx_init(unsigned char *hdr) { unsigned short nfiles = unpack_16_le(hdr+0); unsigned long magic = unpack_32_le(hdr+2); @@ -262,8 +262,13 @@ size_t lbx_file_read(struct lbx_file_state *f, void *buf, size_t n) rc = fops->read(buf, want, f->lbx->f); f->offset += rc; - if (want < n || (rc < want && fops->eof(f->lbx->f))) + if (rc < want) { + if (fops->eof(f->lbx->f)) + lbx_error_raise(LBX_EEOF); + } else if (rc < n) { f->eof = 1; + } + return rc; }