mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 10:37:22 +00:00
3600921 similar code as hpmfwupg reading negative length from failed ftell
This commit is contained in:
parent
4a12bdebd6
commit
83794843b5
@ -90,6 +90,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
||||
static const int IME_SUCCESS = 0;
|
||||
@ -893,13 +894,21 @@ static int ImeImageCtxFromFile(
|
||||
/* Get the raw data in file */
|
||||
fseek(pImageFile, 0, SEEK_END);
|
||||
pImageCtx->size = ftell(pImageFile);
|
||||
if (pImageCtx->size <= 0) {
|
||||
if (pImageCtx->size < 0)
|
||||
lprintf(LOG_ERR, "Error seeking %s. %s\n", imageFilename, strerror(errno));
|
||||
rc = IME_ERROR;
|
||||
fclose(pImageFile);
|
||||
return rc;
|
||||
}
|
||||
pImageCtx->pData = malloc(sizeof(unsigned char)*pImageCtx->size);
|
||||
rewind(pImageFile);
|
||||
|
||||
if ( pImageCtx->pData != NULL )
|
||||
{
|
||||
fread(pImageCtx->pData, sizeof(unsigned char),
|
||||
pImageCtx->size, pImageFile);
|
||||
if (pImageCtx->size < fread(pImageCtx->pData, sizeof(unsigned char),
|
||||
pImageCtx->size, pImageFile))
|
||||
rc = IME_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user