Browse code

avutil/lzo: add asserts to be double sure against overflows

These asserts cannot fail since d6af26c55c1ea30f85a7d9edbc373f53be1743ee

Based-on: ccda51b14c0fcae2fad73a24872dce75a7964996
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit cf2b7c01f81c1fb3283a1390c0ca9a2f81f4f4a8)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2014/06/23 21:45:47
Showing 1 changed files
... ...
@@ -22,6 +22,7 @@
22 22
 #include <string.h>
23 23
 
24 24
 #include "avutil.h"
25
+#include "avassert.h"
25 26
 #include "common.h"
26 27
 #include "intreadwrite.h"
27 28
 #include "lzo.h"
... ...
@@ -85,6 +86,7 @@ static inline void copy(LZOContext *c, int cnt)
85 85
 {
86 86
     register const uint8_t *src = c->in;
87 87
     register uint8_t *dst       = c->out;
88
+    av_assert0(cnt >= 0);
88 89
     if (cnt > c->in_end - src) {
89 90
         cnt       = FFMAX(c->in_end - src, 0);
90 91
         c->error |= AV_LZO_INPUT_DEPLETED;
... ...
@@ -116,6 +118,7 @@ static inline void copy(LZOContext *c, int cnt)
116 116
 static inline void copy_backptr(LZOContext *c, int back, int cnt)
117 117
 {
118 118
     register uint8_t *dst       = c->out;
119
+    av_assert0(cnt > 0);
119 120
     if (dst - c->out_start < back) {
120 121
         c->error |= AV_LZO_INVALID_BACKPTR;
121 122
         return;