Program: 72355
Project: 72355
Buggy source:
/** 
 * Discover all devices that reply to a ping on the class-C local area network connected to the given IP address A class-C network has a netmask of /24, or 255.255.255.0. Returns a string representation of a JSON array of devices.  Note that returning the JSONArray directly does not work properly - for some reason, the JSONArray of device objects is not converted into a Javascript array of device objects.
 * @param IPAddress The IP address whose subnet should be scanned.  E.g.,for IP address 192.168.5.7, scan 192.168.5.0 to 192.168.5.255.
 * @param discoveryMethod The discovery method to be used, e.g. nmap.
 * @return A String containing a JSON representation of devices found.
 */
public String discoverDevices(String IPAddress,String discoveryMethod){
  if (_debugging) {
    System.out.println("String_Node_Str" + IPAddress + "String_Node_Str");
  }
  _ipMap.clear();
  _hostIP=IPAddress;
  String baseIP;
  if (IPAddress.lastIndexOf("String_Node_Str") > 0) {
    baseIP=IPAddress.substring(0,IPAddress.lastIndexOf("String_Node_Str"));
    if (discoveryMethod.equalsIgnoreCase("String_Node_Str")) {
      if (_debugging) {
        System.out.println("String_Node_Str");
      }
      _nmap(baseIP);
    }
 else {
      if (System.getProperty("String_Node_Str").substring(0,3).equalsIgnoreCase("String_Node_Str")) {
        _processes=new ArrayList();
        for (int i=0; i <= 255; i++) {
          try {
            Process process=Runtime.getRuntime().exec(_pingWindowsCommand + baseIP + "String_Node_Str"+ i);
            _processes.add(process);
          }
 catch (          IOException e) {
            System.err.println("String_Node_Str" + baseIP + "String_Node_Str"+ i);
          }
        }
        for (int i=0; i < _processes.size(); i++) {
          _readPingWindows(_processes.get(i),baseIP + "String_Node_Str" + i);
        }
        for (int i=0; i < _processes.size(); i++) {
          try {
            _processes.get(i).waitFor();
          }
 catch (          InterruptedException e) {
          }
        }
        _arpWindows();
      }
 else {
        if (_debugging) {
          System.out.println("String_Node_Str" + baseIP);
        }
        _processes=new ArrayList();
        for (int i=0; i <= 255; i++) {
          try {
            Process process=Runtime.getRuntime().exec(_pingLinuxCommand + baseIP + "String_Node_Str"+ i);
            _processes.add(process);
          }
 catch (          IOException e) {
            System.err.println("String_Node_Str" + baseIP + "String_Node_Str"+ i);
          }
        }
        for (int i=0; i < _processes.size(); i++) {
          _readPingLinux(_processes.get(i),baseIP + "String_Node_Str" + i);
        }
        for (int i=0; i < _processes.size(); i++) {
          try {
            _processes.get(i).waitFor();
          }
 catch (          InterruptedException e) {
          }
        }
        _arpLinux();
      }
    }
  }
 else {
    System.err.println("String_Node_Str" + IPAddress + "String_Node_Str"+ IPAddress+ "String_Node_Str");
  }
  JSONArray jArray=new JSONArray();
  if (_ipMap.size() > 0) {
    for (    String key : _ipMap.keySet()) {
      jArray.put(_ipMap.get(key));
    }
    return jArray.toString();
  }
 else {
    System.err.println("String_Node_Str" + IPAddress + "String_Node_Str"+ "String_Node_Str");
    return jArray.toString();
  }
}

Fixed version (ground truth):
/** 
 * Discover all devices that reply to a ping on the class-C local area network connected to the given IP address A class-C network has a netmask of /24, or 255.255.255.0. Returns a string representation of a JSON array of devices.  Note that returning the JSONArray directly does not work properly - for some reason, the JSONArray of device objects is not converted into a Javascript array of device objects.
 * @param IPAddress The IP address whose subnet should be scanned.  E.g.,for IP address 192.168.5.7, scan 192.168.5.0 to 192.168.5.255.
 * @param discoveryMethod The discovery method to be used, e.g. nmap.
 * @return A String containing a JSON representation of devices found.
 */
public String discoverDevices(String IPAddress,String discoveryMethod){
  if (_debugging) {
    System.out.println("String_Node_Str" + IPAddress + "String_Node_Str");
  }
  _ipMap.clear();
  _hostIP=IPAddress;
  String baseIP;
  if (IPAddress.lastIndexOf("String_Node_Str") > 0) {
    baseIP=IPAddress.substring(0,IPAddress.lastIndexOf("String_Node_Str"));
    if (discoveryMethod.equalsIgnoreCase("String_Node_Str")) {
      if (_debugging) {
        System.out.println("String_Node_Str");
      }
      _nmap(baseIP);
    }
 else {
      if (System.getProperty("String_Node_Str").substring(0,3).equalsIgnoreCase("String_Node_Str")) {
        _processes=new ArrayList();
        for (int i=0; i <= 255; i++) {
          try {
            Process process=Runtime.getRuntime().exec(_pingWindowsCommand + baseIP + "String_Node_Str"+ i);
            _processes.add(process);
          }
 catch (          IOException e) {
            System.err.println("String_Node_Str" + baseIP + "String_Node_Str"+ i);
          }
        }
        for (int i=0; i < _processes.size(); i++) {
          _readPingWindows(_processes.get(i),baseIP + "String_Node_Str" + i);
        }
        for (int i=0; i < _processes.size(); i++) {
          try {
            _processes.get(i).waitFor();
          }
 catch (          InterruptedException e) {
          }
        }
        _arpWindows();
      }
 else {
        if (_debugging) {
          System.out.println("String_Node_Str" + baseIP);
        }
        _processes=new ArrayList();
        for (int i=0; i <= 255; i++) {
          try {
            Process process=Runtime.getRuntime().exec(_pingLinuxCommand + baseIP + "String_Node_Str"+ i);
            _processes.add(process);
          }
 catch (          IOException e) {
            System.err.println("String_Node_Str" + baseIP + "String_Node_Str"+ i);
          }
        }
        for (int i=0; i < _processes.size(); i++) {
          _readPingLinux(_processes.get(i),baseIP + "String_Node_Str" + i);
        }
        for (int i=0; i < _processes.size(); i++) {
          try {
            _processes.get(i).waitFor();
          }
 catch (          InterruptedException e) {
          }
        }
        _arpLinux();
      }
    }
  }
 else {
    System.err.println("String_Node_Str" + IPAddress + "String_Node_Str"+ IPAddress+ "String_Node_Str");
  }
  JSONArray jArray=new JSONArray();
  if (_ipMap.size() > 0) {
    for (    Entry<String,JSONObject> entry : _ipMap.entrySet()) {
      jArray.put(entry.getKey());
    }
    return jArray.toString();
  }
 else {
    System.err.println("String_Node_Str" + IPAddress + "String_Node_Str"+ "String_Node_Str");
    return jArray.toString();
  }
}