(ef_open): Fail if file size is not a multiple of record size.
This commit is contained in:
parent
64d8f6babe
commit
3ea02e2519
1 changed files with 9 additions and 2 deletions
|
@ -58,7 +58,7 @@ int
|
||||||
ef_open(int type, int how)
|
ef_open(int type, int how)
|
||||||
{
|
{
|
||||||
struct empfile *ep;
|
struct empfile *ep;
|
||||||
int oflags, size;
|
int oflags, fsiz, size;
|
||||||
|
|
||||||
if (ef_check(type) < 0)
|
if (ef_check(type) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -82,7 +82,14 @@ ef_open(int type, int how)
|
||||||
ep->baseid = 0;
|
ep->baseid = 0;
|
||||||
ep->cids = 0;
|
ep->cids = 0;
|
||||||
ep->flags = (ep->flags & ~EFF_OPEN) | (how ^ ~EFF_CREATE);
|
ep->flags = (ep->flags & ~EFF_OPEN) | (how ^ ~EFF_CREATE);
|
||||||
ep->fids = fsize(ep->fd) / ep->size;
|
fsiz = fsize(ep->fd);
|
||||||
|
if (fsiz % ep->size) {
|
||||||
|
logerror("Can't open %s (file size not a multiple of record size %d)",
|
||||||
|
ep->file, ep->size);
|
||||||
|
close(ep->fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ep->fids = fsiz / ep->size;
|
||||||
if (ep->flags & EFF_MEM)
|
if (ep->flags & EFF_MEM)
|
||||||
ep->csize = ep->fids;
|
ep->csize = ep->fids;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue