Introduction
Introduction Statistics Contact Development Disclaimer Help
libmach: Use long for offset - scc - simple c99 compiler
git clone git://git.simple-cc.org/scc
Log
Files
Refs
Submodules
README
LICENSE
---
commit e776065632d998cb8491dded4d3c809ac272f5fc
parent 11f2d4ad18c54ed4b3147efb7554820173edd38c
Author: Roberto E. Vargas Caballero <[email protected]>
Date: Thu, 20 Feb 2025 10:31:50 +0100
libmach: Use long for offset
As we use standard fseek() and ftell() we cannot support
files that cannot be addressed with longs, so it is better
to check for these problems when reading files and use
long after that point.
Diffstat:
M include/bits/scc/mach.h | 3 +--
M src/libmach/elf/elfread.c | 2 ++
2 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/include/bits/scc/mach.h b/include/bits/scc/mach.h
@@ -84,7 +84,7 @@ struct section {
unsigned long long base;
unsigned long long load;
unsigned long long size;
- unsigned long long offset;
+ long offset;
unsigned flags;
int index;
@@ -112,7 +112,6 @@ struct map {
struct mapsec *seg;
};
-
/**
* @stype: Used internally by libmach
* @dtype: Coff debug type
diff --git a/src/libmach/elf/elfread.c b/src/libmach/elf/elfread.c
@@ -436,6 +436,8 @@ readphdr(Obj *obj, FILE *fp)
if (fread(buf, hdr->phentsize, 1, fp) != 1)
goto err1;
(*u->phdr)(ORDER(obj->type), buf, &phdr[i]);
+ if (phdr[i].offset > LONG_MAX)
+ goto err1;
}
r = 1;
You are viewing proxied material from simple-cc.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.