]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - lib/lz4/lz4_decompress.c
Merge tag 'pm+acpi-3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[karo-tx-linux.git] / lib / lz4 / lz4_decompress.c
index b74da447e81e1fb28a656abe6359d33d49535765..7a85967060a518a43c5da9125a03d701ab892304 100644 (file)
@@ -192,6 +192,8 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest,
                        int s = 255;
                        while ((ip < iend) && (s == 255)) {
                                s = *ip++;
+                               if (unlikely(length > (size_t)(length + s)))
+                                       goto _output_error;
                                length += s;
                        }
                }
@@ -232,6 +234,8 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest,
                if (length == ML_MASK) {
                        while (ip < iend) {
                                int s = *ip++;
+                               if (unlikely(length > (size_t)(length + s)))
+                                       goto _output_error;
                                length += s;
                                if (s == 255)
                                        continue;
@@ -284,7 +288,7 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest,
 
        /* write overflow error detected */
 _output_error:
-       return (int) (-(((char *) ip) - source));
+       return -1;
 }
 
 int lz4_decompress(const unsigned char *src, size_t *src_len,