Check memsize against filesize before writing
This commit is contained in:
parent
827b48d769
commit
cd34f8c798
@ -209,7 +209,7 @@ static int butterfly_get_memtype(struct multiboot * p_mboot,
|
||||
/* *************************************************************************
|
||||
* butterfly_get_memsize
|
||||
* ************************************************************************* */
|
||||
static int butterfly_get_memsize(struct multiboot * p_mboot,
|
||||
static uint32_t butterfly_get_memsize(struct multiboot * p_mboot,
|
||||
int memtype)
|
||||
{
|
||||
bfly_privdata_t * p_priv = (bfly_privdata_t *)p_mboot->privdata;
|
||||
|
@ -267,7 +267,7 @@ static int eprog_get_memtype(struct multiboot *mboot,
|
||||
/* *************************************************************************
|
||||
* eprog_get_memsize
|
||||
* ************************************************************************* */
|
||||
static int eprog_get_memsize(struct multiboot *mboot,
|
||||
static uint32_t eprog_get_memsize(struct multiboot *mboot,
|
||||
int memtype)
|
||||
{
|
||||
struct eprog_privdata *p_prog = (struct eprog_privdata *)mboot->privdata;
|
||||
|
2
funk.c
2
funk.c
@ -279,7 +279,7 @@ static int funk_get_memtype(struct multiboot *mboot,
|
||||
/* *************************************************************************
|
||||
* funk_get_memsize
|
||||
* ************************************************************************* */
|
||||
static int funk_get_memsize(struct multiboot *mboot,
|
||||
static uint32_t funk_get_memsize(struct multiboot *mboot,
|
||||
int memtype)
|
||||
{
|
||||
struct funk_privdata *funk = (struct funk_privdata *)mboot->privdata;
|
||||
|
2
mpm.c
2
mpm.c
@ -197,7 +197,7 @@ static int mpm_get_memtype(struct multiboot *mboot,
|
||||
/* *************************************************************************
|
||||
* mpm_get_memsize
|
||||
* ************************************************************************* */
|
||||
static int mpm_get_memsize(struct multiboot *mboot, int memtype)
|
||||
static uint32_t mpm_get_memsize(struct multiboot *mboot, int memtype)
|
||||
{
|
||||
struct mpm_privdata *mpm = (struct mpm_privdata *)mboot->privdata;
|
||||
|
||||
|
@ -374,8 +374,8 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
int memsize = mboot->ops->get_memsize(mboot, action->memtype);
|
||||
if (memsize == 0)
|
||||
uint32_t memsize = mboot->ops->get_memsize(mboot, action->memtype);
|
||||
if ((memsize == 0) || (memsize < dbuf->length))
|
||||
{
|
||||
fprintf(stderr, "invalid memsize: 0x%04x > 0x%04x\n", dbuf->length, memsize);
|
||||
dbuf_free(dbuf);
|
||||
|
@ -21,7 +21,7 @@ struct multiboot_ops
|
||||
void (* free)(struct multiboot *mboot);
|
||||
|
||||
int (* get_memtype)(struct multiboot *mboot, const char *memname);
|
||||
int (* get_memsize)(struct multiboot *mboot, int memtype);
|
||||
uint32_t (* get_memsize)(struct multiboot *mboot, int memtype);
|
||||
|
||||
int (* open)(struct multiboot *mboot);
|
||||
int (* close)(struct multiboot *mboot);
|
||||
|
2
twi.c
2
twi.c
@ -592,7 +592,7 @@ static int twi_get_memtype(struct multiboot *mboot,
|
||||
/* *************************************************************************
|
||||
* twi_get_memsize
|
||||
* ************************************************************************* */
|
||||
static int twi_get_memsize(struct multiboot *mboot,
|
||||
static uint32_t twi_get_memsize(struct multiboot *mboot,
|
||||
int memtype)
|
||||
{
|
||||
struct twi_privdata *twi = (struct twi_privdata *)mboot->privdata;
|
||||
|
Loading…
Reference in New Issue
Block a user