mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47: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 <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
static const int IME_SUCCESS = 0;
|
static const int IME_SUCCESS = 0;
|
||||||
@ -893,13 +894,21 @@ static int ImeImageCtxFromFile(
|
|||||||
/* Get the raw data in file */
|
/* Get the raw data in file */
|
||||||
fseek(pImageFile, 0, SEEK_END);
|
fseek(pImageFile, 0, SEEK_END);
|
||||||
pImageCtx->size = ftell(pImageFile);
|
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);
|
pImageCtx->pData = malloc(sizeof(unsigned char)*pImageCtx->size);
|
||||||
rewind(pImageFile);
|
rewind(pImageFile);
|
||||||
|
|
||||||
if ( pImageCtx->pData != NULL )
|
if ( pImageCtx->pData != NULL )
|
||||||
{
|
{
|
||||||
fread(pImageCtx->pData, sizeof(unsigned char),
|
if (pImageCtx->size < fread(pImageCtx->pData, sizeof(unsigned char),
|
||||||
pImageCtx->size, pImageFile);
|
pImageCtx->size, pImageFile))
|
||||||
|
rc = IME_ERROR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user