struct lbx_file_state *last_file;
- unsigned long offsets[];
+ unsigned long offsets[FLEXIBLE_ARRAY_MEMBER];
};
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);
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;
}
case SEEK_END:
pos = f->limit + offset;
break;
+ default:
+ lbx_error_raise(LBX_EINVAL);
+ return -1;
}
- if (pos > f->limit)
+ if (pos > f->limit) {
+ lbx_error_raise(LBX_EINVAL);
return -1;
+ }
f->lbx->last_file = NULL;
if (fops->seek(f->lbx->f, f->base + pos, SEEK_SET) != 0)