syslinux-6.02-fix-chainloading.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. Reported-by: Dark Raven <drdarkraven at gmail.com>
  2. Signed-off-by: Raphael S. Carvalho <raphael.scarv at gmail.com>
  3. ---
  4. com32/lib/syslinux/disk.c | 22 ++++++++++++++--------
  5. 1 files changed, 14 insertions(+), 8 deletions(-)
  6. diff --git a/com32/lib/syslinux/disk.c b/com32/lib/syslinux/disk.c
  7. index 0b0c737..47ecb52 100644
  8. --- a/com32/lib/syslinux/disk.c
  9. +++ b/com32/lib/syslinux/disk.c
  10. @@ -171,22 +171,28 @@ out:
  11. static void *ebios_setup(const struct disk_info *const diskinfo, com32sys_t *inreg,
  12. uint64_t lba, uint8_t count, uint8_t op_code)
  13. {
  14. - static __lowmem struct disk_ebios_dapa dapa;
  15. + static struct disk_ebios_dapa *dapa = NULL;
  16. void *buf;
  17. + if (!dapa) {
  18. + dapa = lmalloc(sizeof *dapa);
  19. + if (!dapa)
  20. + return NULL;
  21. + }
  22. +
  23. buf = lmalloc(count * diskinfo->bps);
  24. if (!buf)
  25. return NULL;
  26. - dapa.len = sizeof(dapa);
  27. - dapa.count = count;
  28. - dapa.off = OFFS(buf);
  29. - dapa.seg = SEG(buf);
  30. - dapa.lba = lba;
  31. + dapa->len = sizeof(*dapa);
  32. + dapa->count = count;
  33. + dapa->off = OFFS(buf);
  34. + dapa->seg = SEG(buf);
  35. + dapa->lba = lba;
  36. inreg->eax.b[1] = op_code;
  37. - inreg->esi.w[0] = OFFS(&dapa);
  38. - inreg->ds = SEG(&dapa);
  39. + inreg->esi.w[0] = OFFS(dapa);
  40. + inreg->ds = SEG(dapa);
  41. inreg->edx.b[0] = diskinfo->disk;
  42. return buf;