bug 8664: Enforcing maximum pagesize limit to 500 to avoid DOS attack against the server.

This commit is contained in:
nit 2011-02-22 19:25:53 +05:30
parent 2efdc9d62b
commit b5152e27ec
1 changed files with 8 additions and 4 deletions

12
api/src/com/cloud/api/BaseListCmd.java Normal file → Executable file
View File

@ -1,11 +1,14 @@
package com.cloud.api;
import com.cloud.async.AsyncJob;
import com.cloud.exception.InvalidParameterValueException;
public abstract class BaseListCmd extends BaseCmd {
/////////////////////////////////////////////////////
private static final Long MAX_PAGESIZE = 500L;
/////////////////////////////////////////////////////
/////////// BaseList API parameters /////////////////
/////////////////////////////////////////////////////
@ -39,10 +42,11 @@ public abstract class BaseListCmd extends BaseCmd {
Long pageSize = null;
Integer pageSizeInt = getPageSize();
if (pageSizeInt != null) {
if (pageSizeInt.longValue() == -1) {
pageSize = pageSizeInt.longValue();
if (pageSize == -1) {
pageSize = null;
} else {
pageSize = pageSizeInt.longValue();
} else if (pageSize > MAX_PAGESIZE){
throw new InvalidParameterValueException("The parameter " +ApiConstants.PAGE_SIZE+ " exceeded its max value - "+MAX_PAGESIZE);
}
}
return pageSize;