From 7231daa71d183a016395d680c659d2f8acaea783 Mon Sep 17 00:00:00 2001 From: Rajani Karuturi Date: Fri, 23 Jan 2015 12:28:27 +0530 Subject: [PATCH] volume upload: fixed the post body parsing logic as long as the boundary is completely in the byte buffer it works. --- .../storage/resource/NfsSecondaryStorageResource.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java index 5227659f6f1..907d4ff5e55 100755 --- a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java +++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java @@ -44,6 +44,7 @@ import java.net.UnknownHostException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -2903,6 +2904,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S output.write(bytebuf[i]); i++; } + readBytes = readBytes - read + i; + input.reset(); + input.skip(readBytes); break; } if (stringBuf.contains("-")) { @@ -2911,13 +2915,16 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S output.write(bytebuf[i]); i++; } - readBytes+=i; + readBytes = readBytes - read + i; input.reset(); input.skip(readBytes); } else { output.write(bytebuf,0,1024); } } + Arrays.fill(bytebuf, (byte)0); + input.read(bytebuf,0,1024); + reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(bytebuf))); } }