Skip to content

Commit 86d29c4

Browse files
committed
CLOUDSTACK-8749: Add checks to prevent malformed/unexpected input
Based on @jburwell's comment on PR #718 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 0b4f972 commit 86d29c4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import javax.naming.ConfigurationException;
2828

29+
import com.google.common.base.Strings;
2930
import org.apache.log4j.Logger;
3031
import org.libvirt.LibvirtException;
3132

@@ -286,7 +287,11 @@ private void deleteExitingLinkLocalRouteTable(String linkLocalBr) {
286287
String[] lines = parser.getLines().split("\\n");
287288
for (String line : lines) {
288289
String[] tokens = line.split(" ");
289-
if (!tokens[2].equalsIgnoreCase(linkLocalBr)) {
290+
if (tokens != null && tokens.length < 2) {
291+
continue;
292+
}
293+
final String device = tokens[2];
294+
if (!Strings.isNullOrEmpty(device) && !device.equalsIgnoreCase(linkLocalBr)) {
290295
Script.runSimpleBashScript("ip route del " + NetUtils.getLinkLocalCIDR() + " dev " + tokens[2]);
291296
} else {
292297
foundLinkLocalBr = true;

0 commit comments

Comments
 (0)