Program: 1011
Project: 1011
Buggy source:
/** 
 * Read the variables from the supplicant daemon that are needed to fill in the WifiConfiguration object.
 * @param config the {@link WifiConfiguration} object to be filled in.
 */
private void readNetworkVariables(WifiConfiguration config){
  int netId=config.networkId;
  if (netId < 0)   return;
  String value;
  value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.ssidVarName);
  if (!TextUtils.isEmpty(value)) {
    if (value.charAt(0) != '"') {
      config.SSID="String_Node_Str" + WifiSsid.createFromHex(value).toString() + "String_Node_Str";
    }
 else {
      config.SSID=value;
    }
  }
 else {
    config.SSID=null;
  }
  value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.bssidVarName);
  if (!TextUtils.isEmpty(value)) {
    config.BSSID=value;
  }
 else {
    config.BSSID=null;
  }
  value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.priorityVarName);
  config.priority=-1;
  if (!TextUtils.isEmpty(value)) {
    try {
      config.priority=Integer.parseInt(value);
    }
 catch (    NumberFormatException ignore) {
    }
  }
  value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.hiddenSSIDVarName);
  config.hiddenSSID=false;
  if (!TextUtils.isEmpty(value)) {
    try {
      config.hiddenSSID=Integer.parseInt(value) != 0;
    }
 catch (    NumberFormatException ignore) {
    }
  }
  value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.wepTxKeyIdxVarName);
  config.wepTxKeyIndex=-1;
  if (!TextUtils.isEmpty(value)) {
    try {
      config.wepTxKeyIndex=Integer.parseInt(value);
    }
 catch (    NumberFormatException ignore) {
    }
  }
  for (int i=0; i < 4; i++) {
    value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.wepKeyVarNames[i]);
    if (!TextUtils.isEmpty(value)) {
      config.wepKeys[i]=value;
    }
 else {
      config.wepKeys[i]=null;
    }
  }
  value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.pskVarName);
  if (!TextUtils.isEmpty(value)) {
    config.preSharedKey=value;
  }
 else {
    config.preSharedKey=null;
  }
  value=mWifiNative.getNetworkVariable(config.networkId,WifiConfiguration.Protocol.varName);
  if (!TextUtils.isEmpty(value)) {
    String vals[]=value.split("String_Node_Str");
    for (    String val : vals) {
      int index=lookupString(val,WifiConfiguration.Protocol.strings);
      if (0 <= index) {
        config.allowedProtocols.set(index);
      }
    }
  }
  value=mWifiNative.getNetworkVariable(config.networkId,WifiConfiguration.KeyMgmt.varName);
  if (!TextUtils.isEmpty(value)) {
    String vals[]=value.split("String_Node_Str");
    for (    String val : vals) {
      int index=lookupString(val,WifiConfiguration.KeyMgmt.strings);
      if (0 <= index) {
        config.allowedKeyManagement.set(index);
      }
    }
  }
  value=mWifiNative.getNetworkVariable(config.networkId,WifiConfiguration.AuthAlgorithm.varName);
  if (!TextUtils.isEmpty(value)) {
    String vals[]=value.split("String_Node_Str");
    for (    String val : vals) {
      int index=lookupString(val,WifiConfiguration.AuthAlgorithm.strings);
      if (0 <= index) {
        config.allowedAuthAlgorithms.set(index);
      }
    }
  }
  value=mWifiNative.getNetworkVariable(config.networkId,WifiConfiguration.PairwiseCipher.varName);
  if (!TextUtils.isEmpty(value)) {
    String vals[]=value.split("String_Node_Str");
    for (    String val : vals) {
      int index=lookupString(val,WifiConfiguration.PairwiseCipher.strings);
      if (0 <= index) {
        config.allowedPairwiseCiphers.set(index);
      }
    }
  }
  value=mWifiNative.getNetworkVariable(config.networkId,WifiConfiguration.GroupCipher.varName);
  if (!TextUtils.isEmpty(value)) {
    String vals[]=value.split("String_Node_Str");
    for (    String val : vals) {
      int index=lookupString(val,WifiConfiguration.GroupCipher.strings);
      if (0 <= index) {
        config.allowedGroupCiphers.set(index);
      }
    }
  }
  if (config.enterpriseConfig == null) {
    config.enterpriseConfig=new WifiEnterpriseConfig();
  }
  HashMap<String,String> enterpriseFields=config.enterpriseConfig.getFields();
  for (  String key : WifiEnterpriseConfig.getSupplicantKeys()) {
    value=mWifiNative.getNetworkVariable(netId,key);
    if (!TextUtils.isEmpty(value)) {
      enterpriseFields.put(key,removeDoubleQuotes(value));
    }
 else {
      enterpriseFields.put(key,WifiEnterpriseConfig.EMPTY_VALUE);
    }
  }
  if (config.enterpriseConfig.migrateOldEapTlsNative(mWifiNative,netId)) {
    saveConfig();
  }
  config.enterpriseConfig.migrateCerts(mKeyStore);
}

Fixed version (ground truth):
/** 
 * Read the variables from the supplicant daemon that are needed to fill in the WifiConfiguration object.
 * @param config the {@link WifiConfiguration} object to be filled in.
 */
private void readNetworkVariables(WifiConfiguration config){
  int netId=config.networkId;
  if (netId < 0)   return;
  String value;
  value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.ssidVarName);
  if (!TextUtils.isEmpty(value)) {
    if (value.charAt(0) != '"') {
      config.SSID="String_Node_Str" + WifiSsid.createFromHex(value).toString() + "String_Node_Str";
    }
 else {
      config.SSID=value;
    }
  }
 else {
    config.SSID=null;
  }
  value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.bssidVarName);
  if (!TextUtils.isEmpty(value)) {
    config.BSSID=value;
  }
 else {
    config.BSSID=null;
  }
  value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.priorityVarName);
  config.priority=-1;
  if (!TextUtils.isEmpty(value)) {
    try {
      config.priority=Integer.parseInt(value);
    }
 catch (    NumberFormatException ignore) {
    }
  }
  value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.hiddenSSIDVarName);
  config.hiddenSSID=false;
  if (!TextUtils.isEmpty(value)) {
    try {
      config.hiddenSSID=Integer.parseInt(value) != 0;
    }
 catch (    NumberFormatException ignore) {
    }
  }
  value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.wepTxKeyIdxVarName);
  config.wepTxKeyIndex=-1;
  if (!TextUtils.isEmpty(value)) {
    try {
      config.wepTxKeyIndex=Integer.parseInt(value);
    }
 catch (    NumberFormatException ignore) {
    }
  }
  for (int i=0; i < 4; i++) {
    value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.wepKeyVarNames[i]);
    if (!TextUtils.isEmpty(value)) {
      config.wepKeys[i]=value;
    }
 else {
      config.wepKeys[i]=null;
    }
  }
  value=mWifiNative.getNetworkVariable(netId,WifiConfiguration.pskVarName);
  if (!TextUtils.isEmpty(value)) {
    config.preSharedKey=value;
  }
 else {
    config.preSharedKey=null;
  }
  value=mWifiNative.getNetworkVariable(config.networkId,WifiConfiguration.Protocol.varName);
  if (!TextUtils.isEmpty(value)) {
    String vals[]=value.split("String_Node_Str");
    for (    String val : vals) {
      int index=lookupString(val,WifiConfiguration.Protocol.strings);
      if (0 <= index) {
        config.allowedProtocols.set(index);
      }
    }
  }
  value=mWifiNative.getNetworkVariable(config.networkId,WifiConfiguration.KeyMgmt.varName);
  if (!TextUtils.isEmpty(value)) {
    String vals[]=value.split("String_Node_Str");
    for (    String val : vals) {
      int index=lookupString(val,WifiConfiguration.KeyMgmt.strings);
      if (0 <= index) {
        config.allowedKeyManagement.set(index);
      }
    }
  }
  value=mWifiNative.getNetworkVariable(config.networkId,WifiConfiguration.AuthAlgorithm.varName);
  if (!TextUtils.isEmpty(value)) {
    String vals[]=value.split("String_Node_Str");
    for (    String val : vals) {
      int index=lookupString(val,WifiConfiguration.AuthAlgorithm.strings);
      if (0 <= index) {
        config.allowedAuthAlgorithms.set(index);
      }
    }
  }
  value=mWifiNative.getNetworkVariable(config.networkId,WifiConfiguration.PairwiseCipher.varName);
  if (!TextUtils.isEmpty(value)) {
    String vals[]=value.split("String_Node_Str");
    for (    String val : vals) {
      int index=lookupString(val,WifiConfiguration.PairwiseCipher.strings);
      if (0 <= index) {
        config.allowedPairwiseCiphers.set(index);
      }
    }
  }
  value=mWifiNative.getNetworkVariable(config.networkId,WifiConfiguration.GroupCipher.varName);
  if (!TextUtils.isEmpty(value)) {
    String vals[]=value.split("String_Node_Str");
    for (    String val : vals) {
      int index=lookupString(val,WifiConfiguration.GroupCipher.strings);
      if (0 <= index) {
        config.allowedGroupCiphers.set(index);
      }
    }
  }
  if (config.enterpriseConfig == null) {
    config.enterpriseConfig=new WifiEnterpriseConfig();
  }
  HashMap<String,String> enterpriseFields=config.enterpriseConfig.getFields();
  for (  String key : WifiEnterpriseConfig.getSupplicantKeys()) {
    value=mWifiNative.getNetworkVariable(netId,key);
    if (!TextUtils.isEmpty(value)) {
      enterpriseFields.put(key,removeDoubleQuotes(value));
    }
 else {
      enterpriseFields.put(key,WifiEnterpriseConfig.EMPTY_VALUE);
    }
  }
  if (config.enterpriseConfig.migrateOldEapTlsNative(mWifiNative,netId)) {
    saveConfig();
  }
  config.enterpriseConfig.migrateCerts(mKeyStore);
  config.enterpriseConfig.initializeSoftwareKeystoreFlag(mKeyStore);
}