wok rev 21820

syslinux/kbd: check kbd malloc pointer
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Aug 25 11:41:26 2019 +0200 (3 months ago)
parents 8637af3e2aba
children 54edd52e6caa
files syslinux/stuff/extra/md5sum.c
line diff
     1.1 --- a/syslinux/stuff/extra/md5sum.c	Sun Aug 25 11:13:41 2019 +0200
     1.2 +++ b/syslinux/stuff/extra/md5sum.c	Sun Aug 25 11:41:26 2019 +0200
     1.3 @@ -626,13 +626,15 @@
     1.4  	loadfile(kbdfile, (void **) &kbdmap, &map_size))
     1.5      	goto kbdmap_error;
     1.6      if (* (short *) kbdmap == 0x005D) {
     1.7 +	void *heap = malloc(2*(1846 + (768 << (3 + 0))) + 16);
     1.8  	void *p = malloc(map_size = * (long *) (kbdmap + 5));
     1.9 -	void *heap = malloc(2*(1846 + (768 << (3 + 0))) + 16);
    1.10  
    1.11 -	unlzma(kbdmap, p, heap);
    1.12 -	free(heap);
    1.13 -	free(kbdmap);
    1.14 -	kbdmap = p;
    1.15 +	if (p) {
    1.16 +		unlzma(kbdmap, p, heap);
    1.17 +		free(heap);
    1.18 +		free(kbdmap);
    1.19 +		kbdmap = p;
    1.20 +	}
    1.21      }
    1.22      if (strncmp(kbdmap, "07070", 5))
    1.23      	goto kbdmap_error;