Skip to content

Commit 25c8cee

Browse files
committed
CLOUDSTACK-4346 uses of parseInt and parseLong secured
1 parent 947f49d commit 25c8cee

4 files changed

Lines changed: 11 additions & 6 deletions

File tree

plugins/network-elements/bigswitch-vns/src/com/cloud/network/guru/BigSwitchVnsGuestNetworkGuru.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ public Network implement(Network network, NetworkOffering offering,
165165
throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a " +
166166
"part of network " + network + " implement ", DataCenter.class, dcId);
167167
}
168+
// when supporting more types of networks this need to become
169+
// int vlan = Integer.parseInt(BroadcastDomainType.getValue(vnet));
168170
int vlan = Integer.parseInt(vnet);
169171

170172
// Name is either the given name or the uuid

plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import com.cloud.agent.api.to.PortForwardingRuleTO;
6666
import com.cloud.agent.api.to.StaticNatRuleTO;
6767
import com.cloud.host.Host;
68+
import com.cloud.network.Networks.BroadcastDomainType;
6869
import com.cloud.network.rules.FirewallRule;
6970
import com.cloud.network.rules.FirewallRule.Purpose;
7071
import com.cloud.resource.ServerResource;
@@ -698,8 +699,7 @@ private Answer execute(IpAssocCommand cmd, int numRetries) {
698699
Long publicVlanTag = null;
699700
if (ip.getVlanId() != null && !ip.getVlanId().equals("untagged")) {
700701
try {
701-
// TODO BroadcastDomain.getValue(ip.getVlanId) ???
702-
publicVlanTag = Long.parseLong(ip.getVlanId());
702+
publicVlanTag = Long.parseLong(BroadcastDomainType.getValue(ip.getVlanId()));
703703
} catch (Exception e) {
704704
throw new ExecutionException("Could not parse public VLAN tag: " + ip.getVlanId());
705705
}
@@ -3581,7 +3581,8 @@ private Long getVlanTag(String vlan) throws ExecutionException {
35813581
Long publicVlanTag = null;
35823582
if (!vlan.equals("untagged")) {
35833583
try {
3584-
publicVlanTag = Long.parseLong(vlan);
3584+
// make sure this vlan is numeric
3585+
publicVlanTag = Long.parseLong(BroadcastDomainType.getValue(vlan));
35853586
} catch (Exception e) {
35863587
throw new ExecutionException("Unable to parse VLAN tag: " + vlan);
35873588
}

server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ public Network implement(Network config, NetworkOffering offering, DeployDestina
143143
UseSystemGuestVlans.valueIn(config.getAccountId()));
144144

145145
try {
146+
// when supporting more types of networks this need to become
147+
// int vlantag = Integer.parseInt(BroadcastDomainType.getValue(vnet));
146148
vlanTag = Integer.parseInt(vnet);
147149
} catch (NumberFormatException e) {
148150
throw new CloudRuntimeException("Obtained an invalid guest vlan tag. Exception: " + e.getMessage());

vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,10 @@ public static Pair<ManagedObjectReference, String> prepareNetwork(String physica
499499

500500
if(vlanId != null && !UNTAGGED_VLAN_NAME.equalsIgnoreCase(vlanId)) {
501501
createGCTag = true;
502-
vid = Integer.parseInt(vlanId);
502+
vid = Integer.parseInt(BroadcastDomainType.getValue(vlanId));
503503
}
504504
if (secondaryvlanId != null) {
505-
spvlanid = Integer.parseInt(secondaryvlanId);
505+
spvlanid = Integer.parseInt(BroadcastDomainType.getValue(secondaryvlanId));
506506
}
507507
}
508508

@@ -937,7 +937,7 @@ public static Pair<ManagedObjectReference, String> prepareNetwork(String vSwitch
937937

938938
if(vlanId != null && !UNTAGGED_VLAN_NAME.equalsIgnoreCase(vlanId) ) {
939939
createGCTag = true;
940-
vid = Integer.parseInt(vlanId);
940+
vid = Integer.parseInt(BroadcastDomainType.getValue(vlanId));
941941
}
942942
}
943943

0 commit comments

Comments
 (0)