wok-6.x rev 18801

syslinux: auto unlzma needs size to work
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jan 11 17:54:50 2016 +0100 (2016-01-11)
parents ad074da5360c
children 429407501864
files syslinux/stuff/extra/loadhigh.u
line diff
     1.1 --- a/syslinux/stuff/extra/loadhigh.u	Sun Jan 10 21:57:16 2016 +0100
     1.2 +++ b/syslinux/stuff/extra/loadhigh.u	Mon Jan 11 17:54:50 2016 +0100
     1.3 @@ -12,34 +12,33 @@
     1.4   
     1.5   #define MAX_CHUNK	(1 << 20) /* 1 MB */
     1.6   
     1.7 -@@ -51,6 +56,10 @@
     1.8 +@@ -51,6 +56,9 @@
     1.9       uint32_t sector_mask;
    1.10       size_t pad;
    1.11       uint32_t retflags = 0;
    1.12  +#ifdef LZLOAD
    1.13  +    char *unpacked = (char *) regs->edi.l;
    1.14 -+    size_t unpackedsz;
    1.15  +#endif
    1.16   
    1.17       bytes     = regs->eax.l;
    1.18       zero_mask = regs->edx.w[0];
    1.19 -@@ -101,6 +110,27 @@
    1.20 +@@ -101,6 +109,27 @@
    1.21   	    break;
    1.22   	}
    1.23       }
    1.24  +
    1.25  +#ifdef LZLOAD
    1.26 -+    unpackedsz = buf - unpacked;
    1.27  +    switch (* (short *) unpacked) {
    1.28  +	char *packed;
    1.29 ++	size_t packedsz, unpackedsz;
    1.30  +    case 0x005D:
    1.31 -+	packed = unpacked + * (unsigned long *) (unpacked + 5)
    1.32 -+			- unpackedsz + 1024;
    1.33 -+
    1.34 -+	if (packed < unpacked + 1024)
    1.35 -+		packed = unpacked + 1024;
    1.36 -+	memmove(packed, unpacked, unpackedsz);
    1.37 -+	unlzma(packed, unpacked, packed + unpackedsz /* head */);
    1.38 ++  	packedsz = buf - unpacked;
    1.39 ++	unpackedsz = * (unsigned long *) (unpacked + 5);
    1.40 ++	if (unpackedsz > 1000000) break; /* no size? */
    1.41 ++	packed = unpacked + unpackedsz - packedsz + 1024;
    1.42 ++	if (packed < unpacked + 1024) packed = unpacked + 1024;
    1.43 ++	memmove(packed, unpacked, packedsz);
    1.44 ++	unlzma(packed, unpacked, packed + packedsz /* heap */);
    1.45  +	buf = packed;
    1.46  +	break;
    1.47  +    case 0x2204: