uses of parseInt and parseLong secured

This commit is contained in:
Daan Hoogland 2013-09-04 09:20:42 +02:00
parent 79e239e307
commit f8fb422612
4 changed files with 11 additions and 6 deletions

View File

@ -165,6 +165,8 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a " +
"part of network " + network + " implement ", DataCenter.class, dcId);
}
// when supporting more types of networks this need to become
// int vlan = Integer.parseInt(BroadcastDomainType.getValue(vnet));
int vlan = Integer.parseInt(vnet);
// Name is either the given name or the uuid

View File

@ -65,6 +65,7 @@ import com.cloud.agent.api.to.IpAddressTO;
import com.cloud.agent.api.to.PortForwardingRuleTO;
import com.cloud.agent.api.to.StaticNatRuleTO;
import com.cloud.host.Host;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.FirewallRule.Purpose;
import com.cloud.resource.ServerResource;
@ -698,8 +699,7 @@ public class JuniperSrxResource implements ServerResource {
Long publicVlanTag = null;
if (ip.getVlanId() != null && !ip.getVlanId().equals("untagged")) {
try {
// TODO BroadcastDomain.getValue(ip.getVlanId) ???
publicVlanTag = Long.parseLong(ip.getVlanId());
publicVlanTag = Long.parseLong(BroadcastDomainType.getValue(ip.getVlanId()));
} catch (Exception e) {
throw new ExecutionException("Could not parse public VLAN tag: " + ip.getVlanId());
}
@ -3581,7 +3581,8 @@ public class JuniperSrxResource implements ServerResource {
Long publicVlanTag = null;
if (!vlan.equals("untagged")) {
try {
publicVlanTag = Long.parseLong(vlan);
// make sure this vlan is numeric
publicVlanTag = Long.parseLong(BroadcastDomainType.getValue(vlan));
} catch (Exception e) {
throw new ExecutionException("Unable to parse VLAN tag: " + vlan);
}

View File

@ -143,6 +143,8 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
UseSystemGuestVlans.valueIn(config.getAccountId()));
try {
// when supporting more types of networks this need to become
// int vlantag = Integer.parseInt(BroadcastDomainType.getValue(vnet));
vlanTag = Integer.parseInt(vnet);
} catch (NumberFormatException e) {
throw new CloudRuntimeException("Obtained an invalid guest vlan tag. Exception: " + e.getMessage());

View File

@ -499,10 +499,10 @@ public class HypervisorHostHelper {
if(vlanId != null && !UNTAGGED_VLAN_NAME.equalsIgnoreCase(vlanId)) {
createGCTag = true;
vid = Integer.parseInt(vlanId);
vid = Integer.parseInt(BroadcastDomainType.getValue(vlanId));
}
if (secondaryvlanId != null) {
spvlanid = Integer.parseInt(secondaryvlanId);
spvlanid = Integer.parseInt(BroadcastDomainType.getValue(secondaryvlanId));
}
}
@ -937,7 +937,7 @@ public class HypervisorHostHelper {
if(vlanId != null && !UNTAGGED_VLAN_NAME.equalsIgnoreCase(vlanId) ) {
createGCTag = true;
vid = Integer.parseInt(vlanId);
vid = Integer.parseInt(BroadcastDomainType.getValue(vlanId));
}
}