Merge tag 'for-linus-5.14-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / lib / decompress_unlz4.c
index c0cfcfd..e632739 100644 (file)
@@ -112,6 +112,9 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,
                                error("data corrupted");
                                goto exit_2;
                        }
+               } else if (size < 4) {
+                       /* empty or end-of-file */
+                       goto exit_3;
                }
 
                chunksize = get_unaligned_le32(inp);
@@ -125,6 +128,10 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,
                        continue;
                }
 
+               if (!fill && chunksize == 0) {
+                       /* empty or end-of-file */
+                       goto exit_3;
+               }
 
                if (posp)
                        *posp += 4;
@@ -184,6 +191,7 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,
                }
        }
 
+exit_3:
        ret = 0;
 exit_2:
        if (!input)