Skip to content

Commit 7cf6aee

Browse files
Likitha Shettychipchilders
authored andcommitted
CLOUDSTACK-1625. NPE with updateResourceCount when && is passed thru API.
If any API contains '&' i.e. no key value pair or '&<paramter-name>' i.e. a parameter without a value, then we get an NPE as owasp.esapi.StringUtilities.stripControls deosn't handle NPE.
1 parent 78f1ab1 commit 7cf6aee

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎server/src/com/cloud/api/ApiServer.java‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,12 @@ public String handleRequest(Map params, String responseType, StringBuffer auditT
327327
}
328328
String[] value = (String[]) params.get(key);
329329
// fail if parameter value contains ASCII control (non-printable) characters
330-
String newValue = StringUtils.stripControlCharacters(value[0]);
331-
if ( !newValue.equals(value[0]) ) {
332-
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Received value " + value[0] + " for parameter "
333-
+ key + " is invalid, contains illegal ASCII non-printable characters");
330+
if (value[0] != null) {
331+
String newValue = StringUtils.stripControlCharacters(value[0]);
332+
if ( !newValue.equals(value[0]) ) {
333+
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Received value " + value[0] + " for parameter "
334+
+ key + " is invalid, contains illegal ASCII non-printable characters");
335+
}
334336
}
335337
paramMap.put(key, value[0]);
336338
}

0 commit comments

Comments
 (0)