From 16ef48f65b62c5fa88fdb1c8cfa92b85d72d7c5a Mon Sep 17 00:00:00 2001 From: Floens Date: Mon, 29 Jan 2018 11:57:37 +0100 Subject: [PATCH] volley: add array length check to streamToBytes. --- .../main/java/com/android/volley/toolbox/DiskBasedCache.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Clover/app/src/main/java/com/android/volley/toolbox/DiskBasedCache.java b/Clover/app/src/main/java/com/android/volley/toolbox/DiskBasedCache.java index bedb66b1..a65a8f4d 100644 --- a/Clover/app/src/main/java/com/android/volley/toolbox/DiskBasedCache.java +++ b/Clover/app/src/main/java/com/android/volley/toolbox/DiskBasedCache.java @@ -322,6 +322,10 @@ public class DiskBasedCache implements Cache { * Reads the contents of an InputStream into a byte[]. * */ private static byte[] streamToBytes(InputStream in, int length) throws IOException { + if (length < 0) { + throw new IOException("length < 0"); + } + byte[] bytes = new byte[length]; int count; int pos = 0;