Sergey Vlasov
2008-Jul-16 11:13 UTC
[syslinux] [PATCH 1/2] chain.c32: fix bounce buffer handling
Fix breakage in the "hide" option support patch: - The code which initialized the global variable "dapa" was lost in commit 81c203f2, therefore EBIOS access did not work properly. Fixed by removing the global variable completely and moving all bounce buffer handling into read_sector() and write_sector(). - write_sector() copied data to the bounce buffer, but then tried to use the pointer to the original buffer in BIOS calls. Signed-off-by: Sergey Vlasov <vsu at altlinux.ru> --- com32/modules/chain.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/com32/modules/chain.c b/com32/modules/chain.c index e6409b4..9ca118c 100644 --- a/com32/modules/chain.c +++ b/com32/modules/chain.c @@ -168,12 +168,13 @@ struct ebios_dapa { uint16_t off; uint16_t seg; uint64_t lba; -} *dapa; +}; static void *read_sector(unsigned int lba) { com32sys_t inreg; - void *buf = __com32.cs_bounce; + struct ebios_dapa *dapa = __com32.cs_bounce; + void *buf = (char *)__com32.cs_bounce + SECTOR; void *data; memset(&inreg, 0, sizeof inreg); @@ -227,11 +228,13 @@ static void *read_sector(unsigned int lba) return data; } -static int write_sector(unsigned int lba, const void *buf) +static int write_sector(unsigned int lba, const void *data) { com32sys_t inreg; + struct ebios_dapa *dapa = __com32.cs_bounce; + void *buf = (char *)__com32.cs_bounce + SECTOR; - memcpy(__com32.cs_bounce, buf, SECTOR); + memcpy(buf, data, SECTOR); memset(&inreg, 0, sizeof inreg); if ( disk_info.ebios ) { -- 1.5.6.2.305.g2938b
Sergey Vlasov
2008-Jul-16 11:13 UTC
[syslinux] [PATCH 2/2] chain.c32: fix test for partition types which can be hidden
The result of shift in C is undefined if the shift count is greater than the width of type. On x86 the corresponding CPU instruction masks the shift count with 0x1f, therefore (mask >> (t & ~0x10)) & 1) gives false positives for types greater than 0x1f (e.g., the partition type 0x8e (Linux LVM) could be "hidden" to 0x9e). Signed-off-by: Sergey Vlasov <vsu at altlinux.ru> --- com32/modules/chain.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/com32/modules/chain.c b/com32/modules/chain.c index 9ca118c..2f79aaf 100644 --- a/com32/modules/chain.c +++ b/com32/modules/chain.c @@ -626,7 +626,7 @@ static int hide_unhide(char *mbr, int part) for (i = 1; i <= 4; i++) { pt = (struct part_entry *)&mbr[0x1be + 16*(i-1)]; t = pt->ostype; - if ((mask >> (t & ~0x10)) & 1) { + if ((t <= 0x1f) && ((mask >> (t & ~0x10)) & 1)) { /* It's a hideable partition type */ if (i == part) t &= ~0x10; /* unhide */ -- 1.5.6.2.305.g2938b