CS-14796. deployVirtualMachine api, added a check to see if the userdata provided is base64 encoded.

Reviewed by: Prachi
This commit is contained in:
Likitha Shetty 2012-08-07 14:14:39 +05:30
parent 44ae760257
commit 0dd17697bb
1 changed files with 3 additions and 0 deletions

View File

@ -2549,6 +2549,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
private void validateUserData(String userData) {
byte[] decodedUserData = null;
if (userData != null) {
if ( !userData.matches("^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$")) {
throw new InvalidParameterValueException("User data is not base64 encoded", null);
}
if (userData.length() >= 2 * MAX_USER_DATA_LENGTH_BYTES) {
throw new InvalidParameterValueException("User data is too long", null);
}