Check i before using it as index

This commit is contained in:
Christophe Grenier 2012-09-10 22:16:40 +02:00
parent 86b2772988
commit 6cbb862854
2 changed files with 2 additions and 2 deletions

View file

@ -1057,7 +1057,7 @@ int fat32_free_info(disk_t *disk_car,const partition_t *partition, const unsigne
int check_VFAT_volume_name(const char *name, const unsigned int max_size) int check_VFAT_volume_name(const char *name, const unsigned int max_size)
{ {
unsigned int i; unsigned int i;
for(i=0;name[i]!='\0' && i<max_size;i++) for(i=0; i<max_size && name[i]!='\0'; i++)
{ {
if(name[i] < 0x20) if(name[i] < 0x20)
return 1; return 1;

View file

@ -640,7 +640,7 @@ static int header_check_mbox(const unsigned char *buffer, const unsigned int buf
{ {
unsigned int i; unsigned int i;
/* From someone@somewhere */ /* From someone@somewhere */
for(i=5; buffer[i]!=' ' && buffer[i]!='@' && i<200; i++); for(i=5; i<200 && buffer[i]!=' ' && buffer[i]!='@'; i++);
if(buffer[i]!='@') if(buffer[i]!='@')
return 0; return 0;
} }