summaryrefslogtreecommitdiff
path: root/lzf_d.c
diff options
context:
space:
mode:
authorroot <root>2006-07-07 15:34:11 +0000
committerroot <root>2006-07-07 15:34:11 +0000
commitc236b409799117eb10770bb7225d10d8409dee35 (patch)
treebf79a84679f4f35aa2f90e96fea6aecef2d79470 /lzf_d.c
parent62f3e819eab18f9d175408dd7421b137132a728d (diff)
*** empty log message ***rel-1_6
Diffstat (limited to 'lzf_d.c')
-rw-r--r--lzf_d.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/lzf_d.c b/lzf_d.c
index d0229d7..73a1a80 100644
--- a/lzf_d.c
+++ b/lzf_d.c
@@ -68,6 +68,14 @@ lzf_decompress (const void *const in_data, unsigned int in_len,
return 0;
}
+#if CHECK_INPUT
+ if (ip + ctrl > in_end)
+ {
+ SET_ERRNO (EINVAL);
+ return 0;
+ }
+#endif
+
#if USE_MEMCPY
memcpy (op, ip, ctrl);
op += ctrl;
@@ -84,9 +92,25 @@ lzf_decompress (const void *const in_data, unsigned int in_len,
u8 *ref = op - ((ctrl & 0x1f) << 8) - 1;
+#if CHECK_INPUT
+ if (ip >= in_end)
+ {
+ SET_ERRNO (EINVAL);
+ return 0;
+ }
+#endif
if (len == 7)
- len += *ip++;
-
+ {
+ len += *ip++;
+#if CHECK_INPUT
+ if (ip >= in_end)
+ {
+ SET_ERRNO (EINVAL);
+ return 0;
+ }
+#endif
+ }
+
ref -= *ip++;
if (op + len + 2 > out_end)
@@ -109,7 +133,7 @@ lzf_decompress (const void *const in_data, unsigned int in_len,
while (--len);
}
}
- while (op < out_end && ip < in_end);
+ while (ip < in_end);
return op - (u8 *)out_data;
}