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