Browse Source

Check memsize against filesize before writing

master
Olaf Rempel 1 week ago
parent
commit
cd34f8c798
7 changed files with 12 additions and 12 deletions
  1. +2
    -2
      butterfly.c
  2. +2
    -2
      eprom_prog.c
  3. +2
    -2
      funk.c
  4. +1
    -1
      mpm.c
  5. +2
    -2
      multiboot.c
  6. +1
    -1
      multiboot.h
  7. +2
    -2
      twi.c

+ 2
- 2
butterfly.c View File

@@ -209,8 +209,8 @@ static int butterfly_get_memtype(struct multiboot * p_mboot,
/* *************************************************************************
* butterfly_get_memsize
* ************************************************************************* */
static int butterfly_get_memsize(struct multiboot * p_mboot,
int memtype)
static uint32_t butterfly_get_memsize(struct multiboot * p_mboot,
int memtype)
{
bfly_privdata_t * p_priv = (bfly_privdata_t *)p_mboot->privdata;



+ 2
- 2
eprom_prog.c View File

@@ -267,8 +267,8 @@ static int eprog_get_memtype(struct multiboot *mboot,
/* *************************************************************************
* eprog_get_memsize
* ************************************************************************* */
static int eprog_get_memsize(struct multiboot *mboot,
int memtype)
static uint32_t eprog_get_memsize(struct multiboot *mboot,
int memtype)
{
struct eprog_privdata *p_prog = (struct eprog_privdata *)mboot->privdata;



+ 2
- 2
funk.c View File

@@ -279,8 +279,8 @@ static int funk_get_memtype(struct multiboot *mboot,
/* *************************************************************************
* funk_get_memsize
* ************************************************************************* */
static int funk_get_memsize(struct multiboot *mboot,
int memtype)
static uint32_t funk_get_memsize(struct multiboot *mboot,
int memtype)
{
struct funk_privdata *funk = (struct funk_privdata *)mboot->privdata;



+ 1
- 1
mpm.c View File

@@ -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;



+ 2
- 2
multiboot.c View File

@@ -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);


+ 1
- 1
multiboot.h View File

@@ -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
- 2
twi.c View File

@@ -592,8 +592,8 @@ static int twi_get_memtype(struct multiboot *mboot,
/* *************************************************************************
* twi_get_memsize
* ************************************************************************* */
static int twi_get_memsize(struct multiboot *mboot,
int memtype)
static uint32_t twi_get_memsize(struct multiboot *mboot,
int memtype)
{
struct twi_privdata *twi = (struct twi_privdata *)mboot->privdata;



Loading…
Cancel
Save