mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-03 09:48:29 +00:00
Fix a bunch of Windows bugs reported on Discord
This change addresses everything from stack smashing to %SYSTEMROOT% breaking socket(). Issues relating to compile.com not reporting text printed to stderr has been resolved for Windows builds.
This commit is contained in:
parent
b0e3258709
commit
5018171fa5
10 changed files with 104 additions and 46 deletions
|
@ -31,17 +31,15 @@
|
|||
* @param shdr is from GetElfSectionHeaderAddress(), or null
|
||||
* @return pointer to section data within image, or null if
|
||||
* 1. `shdr` was null, or
|
||||
* 2. `sh_size` was zero, or
|
||||
* 3, `sh_type` was `SHT_NOBITS`, or
|
||||
* 4. content wasn't contained within `[elf,elf+mapsize)`, or
|
||||
* 5. an arithmetic overflow occurred
|
||||
* 2. content wasn't contained within `[elf,elf+mapsize)`, or
|
||||
* 3. an arithmetic overflow occurred
|
||||
*/
|
||||
void *GetElfSectionAddress(const Elf64_Ehdr *elf, // validated
|
||||
size_t mapsize, // validated
|
||||
const Elf64_Shdr *shdr) { // foreign
|
||||
Elf64_Off last;
|
||||
if (!shdr) return 0;
|
||||
if (shdr->sh_size <= 0) return 0;
|
||||
if (!shdr->sh_size) return elf;
|
||||
if (shdr->sh_type == SHT_NOBITS) return 0;
|
||||
if (ckd_add(&last, shdr->sh_offset, shdr->sh_size)) return 0;
|
||||
if (last > mapsize) return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue