Program: 109719
Project: 109719
Buggy source:
VpnProfile convertProfile() throws ConfigParseError {
  boolean noauthtypeset=true;
  VpnProfile np=new VpnProfile("String_Node_Str");
  np.clearDefaults();
  if (options.containsKey("String_Node_Str") || options.containsKey("String_Node_Str")) {
    np.mUsePull=true;
    options.remove("String_Node_Str");
    options.remove("String_Node_Str");
  }
  Vector<String> secret=getOption("String_Node_Str",1,2);
  if (secret != null) {
    np.mAuthenticationType=VpnProfile.TYPE_STATICKEYS;
    noauthtypeset=false;
    np.mUseTLSAuth=true;
    np.mTLSAuthFilename=secret.get(1);
    if (secret.size() == 3)     np.mTLSAuthDirection=secret.get(2);
  }
  Vector<Vector<String>> routes=getAllOption("String_Node_Str",1,4);
  if (routes != null) {
    String routeopt="String_Node_Str";
    for (    Vector<String> route : routes) {
      String netmask="String_Node_Str";
      if (route.size() >= 3)       netmask=route.get(2);
      String net=route.get(1);
      try {
        CIDRIP cidr=new CIDRIP(net,netmask);
        routeopt+=cidr.toString() + "String_Node_Str";
      }
 catch (      ArrayIndexOutOfBoundsException aioob) {
        throw new ConfigParseError("String_Node_Str" + netmask);
      }
    }
    np.mCustomRoutes=routeopt;
  }
  Vector<Vector<String>> tlsauthoptions=getAllOption("String_Node_Str",1,2);
  if (tlsauthoptions != null) {
    for (    Vector<String> tlsauth : tlsauthoptions) {
      if (tlsauth != null) {
        if (!tlsauth.get(1).equals("String_Node_Str")) {
          np.mTLSAuthFilename=tlsauth.get(1);
          np.mUseTLSAuth=true;
        }
        if (tlsauth.size() == 3)         np.mTLSAuthDirection=tlsauth.get(2);
      }
    }
  }
  Vector<String> direction=getOption("String_Node_Str",1,1);
  if (direction != null)   np.mTLSAuthDirection=direction.get(1);
  if (getAllOption("String_Node_Str",0,5) != null)   np.mUseDefaultRoute=true;
  Vector<String> dev=getOption("String_Node_Str",1,1);
  Vector<String> devtype=getOption("String_Node_Str",1,1);
  if ((devtype != null && devtype.get(1).equals("String_Node_Str")) || (dev != null && dev.get(1).startsWith("String_Node_Str")) || (devtype == null && dev == null)) {
  }
 else {
    throw new ConfigParseError("String_Node_Str");
  }
  Vector<String> mode=getOption("String_Node_Str",1,1);
  if (mode != null) {
    if (!mode.get(1).equals("String_Node_Str"))     throw new ConfigParseError("String_Node_Str");
  }
  Vector<String> remote=getOption("String_Node_Str",1,3);
  if (remote != null) {
switch (remote.size()) {
case 4:
      String proto=remote.get(3);
    if (proto.equals("String_Node_Str"))     np.mUseUdp=true;
 else     if (proto.equals("String_Node_Str"))     np.mUseUdp=false;
 else     throw new ConfigParseError("String_Node_Str");
case 3:
  np.mServerPort=remote.get(2);
case 2:
np.mServerName=remote.get(1);
}
}
Vector<String> port=getOption("String_Node_Str",1,1);
if (port != null) {
np.mServerPort=port.get(1);
}
Vector<String> proto=getOption("String_Node_Str",1,1);
if (proto != null) {
if (proto.get(1).equals("String_Node_Str")) np.mUseUdp=true;
 else if (proto.get(1).equals("String_Node_Str") || proto.get(1).equals("String_Node_Str")) np.mUseUdp=false;
 else throw new ConfigParseError("String_Node_Str" + proto.get(1));
}
Vector<Vector<String>> dhcpoptions=getAllOption("String_Node_Str",2,2);
if (dhcpoptions != null) {
for (Vector<String> dhcpoption : dhcpoptions) {
String type=dhcpoption.get(1);
String arg=dhcpoption.get(2);
if (type.equals("String_Node_Str")) {
np.mSearchDomain=dhcpoption.get(2);
}
 else if (type.equals("String_Node_Str")) {
np.mOverrideDNS=true;
if (np.mDNS1.equals(VpnProfile.DEFAULT_DNS1)) np.mDNS1=arg;
 else np.mDNS2=arg;
}
}
}
Vector<String> ifconfig=getOption("String_Node_Str",2,2);
if (ifconfig != null) {
CIDRIP cidr=new CIDRIP(ifconfig.get(1),ifconfig.get(2));
np.mIPv4Address=cidr.toString();
}
if (getOption("String_Node_Str",0,0) != null) np.mUseRandomHostname=true;
if (getOption("String_Node_Str",0,0) != null) np.mUseFloat=true;
if (getOption("String_Node_Str",0,1) != null) np.mUseLzo=true;
Vector<String> cipher=getOption("String_Node_Str",1,1);
if (cipher != null) np.mCipher=cipher.get(1);
Vector<String> ca=getOption("String_Node_Str",1,1);
if (ca != null) {
np.mCaFilename=ca.get(1);
}
Vector<String> cert=getOption("String_Node_Str",1,1);
if (cert != null) {
np.mClientCertFilename=cert.get(1);
np.mAuthenticationType=VpnProfile.TYPE_CERTIFICATES;
noauthtypeset=false;
}
Vector<String> key=getOption("String_Node_Str",1,1);
if (key != null) np.mClientKeyFilename=key.get(1);
Vector<String> pkcs12=getOption("String_Node_Str",1,1);
if (pkcs12 != null) {
np.mPKCS12Filename=pkcs12.get(1);
np.mAuthenticationType=VpnProfile.TYPE_KEYSTORE;
noauthtypeset=false;
}
Vector<String> tlsremote=getOption("String_Node_Str",1,1);
if (tlsremote != null) {
np.mRemoteCN=tlsremote.get(1);
np.mCheckRemoteCN=true;
}
Vector<String> verb=getOption("String_Node_Str",1,1);
if (verb != null) {
np.mVerb=verb.get(1);
}
if (getOption("String_Node_Str",0,0) != null) np.mNobind=true;
if (getOption("String_Node_Str",0,0) != null) np.mPersistTun=true;
Vector<String> authuser=getOption("String_Node_Str",0,1);
if (authuser != null) {
if (noauthtypeset) {
np.mAuthenticationType=VpnProfile.TYPE_USERPASS;
}
 else if (np.mAuthenticationType == VpnProfile.TYPE_CERTIFICATES) {
np.mAuthenticationType=VpnProfile.TYPE_USERPASS_CERTIFICATES;
}
 else if (np.mAuthenticationType == VpnProfile.TYPE_KEYSTORE) {
np.mAuthenticationType=VpnProfile.TYPE_USERPASS_KEYSTORE;
}
if (authuser.size() > 1) {
np.mUsername=authuser.get(1);
}
}
checkIgnoreAndInvalidOptions(np);
fixup(np);
return np;
}

Fixed version (ground truth):
VpnProfile convertProfile() throws ConfigParseError {
  boolean noauthtypeset=true;
  VpnProfile np=new VpnProfile("String_Node_Str");
  np.clearDefaults();
  if (options.containsKey("String_Node_Str") || options.containsKey("String_Node_Str")) {
    np.mUsePull=true;
    options.remove("String_Node_Str");
    options.remove("String_Node_Str");
  }
  Vector<String> secret=getOption("String_Node_Str",1,2);
  if (secret != null) {
    np.mAuthenticationType=VpnProfile.TYPE_STATICKEYS;
    noauthtypeset=false;
    np.mUseTLSAuth=true;
    np.mTLSAuthFilename=secret.get(1);
    if (secret.size() == 3)     np.mTLSAuthDirection=secret.get(2);
  }
  Vector<Vector<String>> routes=getAllOption("String_Node_Str",1,4);
  if (routes != null) {
    String routeopt="String_Node_Str";
    for (    Vector<String> route : routes) {
      String netmask="String_Node_Str";
      if (route.size() >= 3)       netmask=route.get(2);
      String net=route.get(1);
      try {
        CIDRIP cidr=new CIDRIP(net,netmask);
        routeopt+=cidr.toString() + "String_Node_Str";
      }
 catch (      ArrayIndexOutOfBoundsException aioob) {
        throw new ConfigParseError("String_Node_Str" + netmask);
      }
catch (      NumberFormatException ne) {
        throw new ConfigParseError("String_Node_Str" + netmask);
      }
    }
    np.mCustomRoutes=routeopt;
  }
  Vector<Vector<String>> tlsauthoptions=getAllOption("String_Node_Str",1,2);
  if (tlsauthoptions != null) {
    for (    Vector<String> tlsauth : tlsauthoptions) {
      if (tlsauth != null) {
        if (!tlsauth.get(1).equals("String_Node_Str")) {
          np.mTLSAuthFilename=tlsauth.get(1);
          np.mUseTLSAuth=true;
        }
        if (tlsauth.size() == 3)         np.mTLSAuthDirection=tlsauth.get(2);
      }
    }
  }
  Vector<String> direction=getOption("String_Node_Str",1,1);
  if (direction != null)   np.mTLSAuthDirection=direction.get(1);
  if (getAllOption("String_Node_Str",0,5) != null)   np.mUseDefaultRoute=true;
  Vector<String> dev=getOption("String_Node_Str",1,1);
  Vector<String> devtype=getOption("String_Node_Str",1,1);
  if ((devtype != null && devtype.get(1).equals("String_Node_Str")) || (dev != null && dev.get(1).startsWith("String_Node_Str")) || (devtype == null && dev == null)) {
  }
 else {
    throw new ConfigParseError("String_Node_Str");
  }
  Vector<String> mode=getOption("String_Node_Str",1,1);
  if (mode != null) {
    if (!mode.get(1).equals("String_Node_Str"))     throw new ConfigParseError("String_Node_Str");
  }
  Vector<String> remote=getOption("String_Node_Str",1,3);
  if (remote != null) {
switch (remote.size()) {
case 4:
      String proto=remote.get(3);
    if (proto.equals("String_Node_Str"))     np.mUseUdp=true;
 else     if (proto.equals("String_Node_Str"))     np.mUseUdp=false;
 else     throw new ConfigParseError("String_Node_Str");
case 3:
  np.mServerPort=remote.get(2);
case 2:
np.mServerName=remote.get(1);
}
}
Vector<String> port=getOption("String_Node_Str",1,1);
if (port != null) {
np.mServerPort=port.get(1);
}
Vector<String> proto=getOption("String_Node_Str",1,1);
if (proto != null) {
if (proto.get(1).equals("String_Node_Str")) np.mUseUdp=true;
 else if (proto.get(1).equals("String_Node_Str") || proto.get(1).equals("String_Node_Str")) np.mUseUdp=false;
 else throw new ConfigParseError("String_Node_Str" + proto.get(1));
}
Vector<Vector<String>> dhcpoptions=getAllOption("String_Node_Str",2,2);
if (dhcpoptions != null) {
for (Vector<String> dhcpoption : dhcpoptions) {
String type=dhcpoption.get(1);
String arg=dhcpoption.get(2);
if (type.equals("String_Node_Str")) {
np.mSearchDomain=dhcpoption.get(2);
}
 else if (type.equals("String_Node_Str")) {
np.mOverrideDNS=true;
if (np.mDNS1.equals(VpnProfile.DEFAULT_DNS1)) np.mDNS1=arg;
 else np.mDNS2=arg;
}
}
}
Vector<String> ifconfig=getOption("String_Node_Str",2,2);
if (ifconfig != null) {
CIDRIP cidr=new CIDRIP(ifconfig.get(1),ifconfig.get(2));
np.mIPv4Address=cidr.toString();
}
if (getOption("String_Node_Str",0,0) != null) np.mUseRandomHostname=true;
if (getOption("String_Node_Str",0,0) != null) np.mUseFloat=true;
if (getOption("String_Node_Str",0,1) != null) np.mUseLzo=true;
Vector<String> cipher=getOption("String_Node_Str",1,1);
if (cipher != null) np.mCipher=cipher.get(1);
Vector<String> ca=getOption("String_Node_Str",1,1);
if (ca != null) {
np.mCaFilename=ca.get(1);
}
Vector<String> cert=getOption("String_Node_Str",1,1);
if (cert != null) {
np.mClientCertFilename=cert.get(1);
np.mAuthenticationType=VpnProfile.TYPE_CERTIFICATES;
noauthtypeset=false;
}
Vector<String> key=getOption("String_Node_Str",1,1);
if (key != null) np.mClientKeyFilename=key.get(1);
Vector<String> pkcs12=getOption("String_Node_Str",1,1);
if (pkcs12 != null) {
np.mPKCS12Filename=pkcs12.get(1);
np.mAuthenticationType=VpnProfile.TYPE_KEYSTORE;
noauthtypeset=false;
}
Vector<String> tlsremote=getOption("String_Node_Str",1,1);
if (tlsremote != null) {
np.mRemoteCN=tlsremote.get(1);
np.mCheckRemoteCN=true;
}
Vector<String> verb=getOption("String_Node_Str",1,1);
if (verb != null) {
np.mVerb=verb.get(1);
}
if (getOption("String_Node_Str",0,0) != null) np.mNobind=true;
if (getOption("String_Node_Str",0,0) != null) np.mPersistTun=true;
Vector<String> authuser=getOption("String_Node_Str",0,1);
if (authuser != null) {
if (noauthtypeset) {
np.mAuthenticationType=VpnProfile.TYPE_USERPASS;
}
 else if (np.mAuthenticationType == VpnProfile.TYPE_CERTIFICATES) {
np.mAuthenticationType=VpnProfile.TYPE_USERPASS_CERTIFICATES;
}
 else if (np.mAuthenticationType == VpnProfile.TYPE_KEYSTORE) {
np.mAuthenticationType=VpnProfile.TYPE_USERPASS_KEYSTORE;
}
if (authuser.size() > 1) {
np.mUsername=authuser.get(1);
}
}
checkIgnoreAndInvalidOptions(np);
fixup(np);
return np;
}