Commit 23f64cf5 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

fileRead: check result of fread

parent 43b53d42
2009-12-15 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* fileRead: check result of fread
* binReadF77Block: check result of fileRead
* Version 1.4.1 released
2009-12-11 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* streamSync: check that vlist has variables to sync [report: Martin Schultz]
......
......@@ -67,14 +67,15 @@ UINT64 get_SUINT64(unsigned char *x)
size_t binReadF77Block(int fileID, int byteswap)
{
unsigned char f77block[4];
size_t blocklen;
size_t blocklen = 0;
fileRead(fileID, f77block, 4);
if ( byteswap )
blocklen = get_SUINT32(f77block);
else
blocklen = get_UINT32(f77block);
if ( fileRead(fileID, f77block, 4) == 4 )
{
if ( byteswap )
blocklen = get_SUINT32(f77block);
else
blocklen = get_UINT32(f77block);
}
return (blocklen);
}
......
......@@ -1323,7 +1323,16 @@ size_t filePtrRead(void *vfileptr, void *ptr, size_t size)
if ( fileptr->mode == 'r' && fileptr->type == FILE_TYPE_OPEN )
nread = file_read_from_buffer(fileptr, ptr, size);
else
nread = fread(ptr, 1, size, fileptr->fp);
{
nread = fread(ptr, 1, size, fileptr->fp);
if ( nread != size )
{
if ( nread == 0 )
fileptr->flag |= FILE_EOF;
else
fileptr->flag |= FILE_ERROR;
}
}
fileptr->position += nread;
fileptr->byteTrans += nread;
......@@ -1349,7 +1358,16 @@ size_t fileRead(int fileID, void *ptr, size_t size)
if ( fileptr->mode == 'r' && fileptr->type == FILE_TYPE_OPEN )
nread = file_read_from_buffer(fileptr, ptr, size);
else
nread = fread(ptr, 1, size, fileptr->fp);
{
nread = fread(ptr, 1, size, fileptr->fp);
if ( nread != size )
{
if ( nread == 0 )
fileptr->flag |= FILE_EOF;
else
fileptr->flag |= FILE_ERROR;
}
}
fileptr->position += nread;
fileptr->byteTrans += nread;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment