1
0
Fork 0
mirror of https://gitlab.com/bztsrc/bootboot.git synced 2023-02-13 20:54:32 -05:00

Only match env on line beginning, fixed issue #23

This commit is contained in:
bzt 2020-10-05 19:45:12 +02:00
parent 85a86a3611
commit e8a91d134c
10 changed files with 30 additions and 15 deletions

View file

@ -1110,7 +1110,7 @@ void MapPage(uint64_t virt, uint64_t phys)
*/
void ParseEnvironment(uint8_t *env)
{
uint8_t *end=env+PAGESIZE;
uint8_t *end=env+PAGESIZE, *start=env;
DBG(" * Environment\n");
env--; env[PAGESIZE]=0; kne=NULL;
while(env<end) {
@ -1134,6 +1134,9 @@ void ParseEnvironment(uint8_t *env)
while(env[0]!=0 && env[-1]!='*' && env[0]!='/')
env++;
}
// only match on beginning of line
if(env>start && env[-1]!=' '&&env[-1]!='\t'&&env[-1]!='\r'&&env[-1]!='\n')
continue;
// parse screen dimensions
if(!memcmp(env,"screen=",7)){
env+=7;

BIN
dist/bootboot.bin vendored

Binary file not shown.

BIN
dist/bootboot.efi vendored

Binary file not shown.

BIN
dist/bootboot.img vendored

Binary file not shown.

BIN
dist/bootboot.rom vendored

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -3,8 +3,8 @@
extern unsigned char binary_boot_bin[512];
extern unsigned char binary_bootboot_bin[12288];
extern unsigned char binary_bootboot_efi[100932];
extern unsigned char binary_bootboot_img[34672];
extern unsigned char binary_bootboot_img[34712];
extern unsigned char binary_LICENCE_broadcom[1594];
extern unsigned char binary_bootcode_bin[52480];
extern unsigned char binary_fixup_dat[7274];
extern unsigned char binary_start_elf[3000960];
extern unsigned char binary_fixup_dat[7290];
extern unsigned char binary_start_elf[2949088];

View file

@ -1561,6 +1561,13 @@ end if
cmp esi, 0A000h
ja .parseend
jmp .skipcom2
;only match on beginning of line
@@: cmp esi, 9000h
je @f
cmp byte [esi-1], ' '
je @f
cmp byte [esi-1], 13
jae .next
;parse screen dimensions
@@: cmp dword[esi], 'scre'
jne @f
@ -1577,11 +1584,11 @@ end if
jmp .getnext
;get kernel's filename
@@: cmp dword[esi], 'kern'
jne @f
jne .next
cmp word[esi+4], 'el'
jne @f
jne .next
cmp byte[esi+6], '='
jne @f
jne .next
add esi, 7
mov edi, kernel
.copy: lodsb
@ -1600,8 +1607,7 @@ end if
.copyend: xor al, al
stosb
jmp .getnext
@@:
inc esi
.next: inc esi
;failsafe
.getnext: cmp esi, 0A000h
jae .parseend

View file

@ -517,7 +517,7 @@ ssize_t disk_read(size_t dev_num, lba_t start, size_t count, unsigned char *buf)
*/
void ParseEnvironment(uint8_t *env)
{
uint8_t *end=env+PAGESIZE;
uint8_t *end=env+PAGESIZE, *start=env;
DBG(" * Environment @%p %d bytes\n",env,env ? (int)strlen((char*)env) : 0);
env--; env[PAGESIZE]=0; kne=NULL;
while(env<end) {
@ -541,6 +541,9 @@ void ParseEnvironment(uint8_t *env)
while(env[0]!=0 && env[-1]!='*' && env[0]!='/')
env++;
}
// only match on beginning of line
if(env>start && env[-1]!=' '&&env[-1]!='\t'&&env[-1]!='\r'&&env[-1]!='\n')
continue;
// parse screen dimensions
if(!memcmp(env,"screen=",7)){
env+=7;

View file

@ -1058,6 +1058,9 @@ ParseEnvironment(unsigned char *cfg, int len, INTN argc, CHAR16 **argv)
while(ptr[0]!=0 && ptr[-1]!='*' && ptr[0]!='/')
ptr++;
}
// only match on beginning of line
if(ptr>cfg && ptr[-1]!=' '&&ptr[-1]!='\t'&&ptr[-1]!='\r'&&ptr[-1]!='\n')
continue;
// parse screen dimensions
if(!CompareMem(ptr,(const CHAR8 *)"screen=",7)){
ptr+=7;