[syslinux] fix a crash if the downloaded Syslinux content has been modified

* Some stupid corporate firewalls will return garbage content for ldlinux.bss/ldlinux.sys
  instead of a 403 (as they really should), which creates an issue with the code written
  by the Syslinux people, as they forgot to check for potential overflows...
This commit is contained in:
Pete Batard 2015-10-28 23:17:55 +00:00
parent c12977a164
commit ad68ccfac9
3 changed files with 13 additions and 8 deletions

View file

@ -123,9 +123,11 @@ int syslinux_patch(const sector_t *sectp, int nsectors,
/* Search for LDLINUX_MAGIC to find the patch area */
for (wp = (const uint32_t _slimg *)boot_image;
get_32_sl(wp) != LDLINUX_MAGIC;
(get_32_sl(wp) != LDLINUX_MAGIC) && (((uintptr_t)wp) < ((uintptr_t)boot_image + boot_image_len));
wp++)
;
if (((uintptr_t)wp) >= ((uintptr_t)boot_image + boot_image_len))
return -1;
patcharea = (struct patch_area _slimg *)wp;
epa = slptr(boot_image, &patcharea->epaoffset);