summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rwxr-xr-xsrc/common/endianness.c4
-rw-r--r--src/common/leb128.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/src/common/endianness.c b/src/common/endianness.c
index 5c9b183..3a2a653 100755
--- a/src/common/endianness.c
+++ b/src/common/endianness.c
@@ -44,6 +44,7 @@
bool read_u4(uint8_t *target, const bin_t *data, off_t *pos, off_t len, bool *low, SourceEndian endian)
{
+ if (*pos < 0) return false;
if ((len - *pos) < 1) return false;
if (*low)
@@ -81,6 +82,7 @@ bool read_u4(uint8_t *target, const bin_t *data, off_t *pos, off_t len, bool *lo
bool read_u8(uint8_t *target, const bin_t *data, off_t *pos, off_t len, SourceEndian endian)
{
+ if (*pos < 0) return false;
if ((len - *pos) < 1) return false;
*target = data[*pos];
@@ -110,6 +112,7 @@ bool read_u8(uint8_t *target, const bin_t *data, off_t *pos, off_t len, SourceEn
bool read_u16(uint16_t *target, const bin_t *data, off_t *pos, off_t len, SourceEndian endian)
{
+ if (*pos < 0) return false;
if ((len - *pos) < 2) return false;
switch (endian)
@@ -181,6 +184,7 @@ bool read_u16(uint16_t *target, const bin_t *data, off_t *pos, off_t len, Source
bool read_u32(uint32_t *target, const bin_t *data, off_t *pos, off_t len, SourceEndian endian)
{
+ if (*pos < 0) return false;
if ((len - *pos) < 4) return false;
switch (endian)
diff --git a/src/common/leb128.c b/src/common/leb128.c
index 4a03797..1b65fa7 100644
--- a/src/common/leb128.c
+++ b/src/common/leb128.c
@@ -45,6 +45,8 @@ bool read_uleb128(uleb128_t *target, const bin_t *data, off_t *pos, off_t len)
int shift; /* Décallage à appliquer */
off_t i; /* Boucle de parcours */
+ if (*pos < 0) return false;
+
shift = 0;
*target = 0;
@@ -87,6 +89,8 @@ bool read_leb128(leb128_t *target, const bin_t *data, off_t *pos, off_t len)
int shift; /* Décallage à appliquer */
off_t i; /* Boucle de parcours */
+ if (*pos < 0) return false;
+
shift = 0;
*target = 0;