From 709bfc2cd4a800fc75d231a42e173bab507b814e Mon Sep 17 00:00:00 2001 From: orbiter Date: Tue, 12 May 2009 20:23:55 +0000 Subject: [PATCH] added a memory check in http post protocol git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5949 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/http/httpd.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.java index 115bf7304..6803cd4c2 100644 --- a/source/de/anomic/http/httpd.java +++ b/source/de/anomic/http/httpd.java @@ -68,6 +68,7 @@ import de.anomic.kelondro.util.ByteBuffer; import de.anomic.kelondro.util.DateFormatter; import de.anomic.kelondro.util.Log; import de.anomic.kelondro.util.FileUtils; +import de.anomic.kelondro.util.MemoryControl; import de.anomic.plasma.plasmaSwitchboard; import de.anomic.server.serverCodings; import de.anomic.server.serverCore; @@ -898,6 +899,11 @@ public final class httpd implements serverHandler, Cloneable { if (!FileUploadBase.isMultipartContent(request)) { throw new IOException("the request is not a multipart-message!"); } + + // check if we have enough memory + if (!MemoryControl.request(request.getContentLength() * 3, false)) { + throw new IOException("not enough memory available for request. request.getContentLength() = " + request.getContentLength() + ", MemoryControl.available() = " + MemoryControl.available()); + } // parse data in memory FileItemFactory factory = new DiskFileItemFactory(1024 * 1024, TMPDIR);