Program: 4872
Project: 4872
Buggy source:
/** 
 * Build a new query with data snatched from network
 * @requires payload.length>=3
 */
public QueryRequest(byte[] guid,byte ttl,byte hops,byte[] payload){
  super(guid,Message.F_QUERY,ttl,hops,payload.length);
  if (payload == null) {
    this.payload=EMPTY_BYTE_ARRAY;
  }
 else {
    this.payload=payload;
  }
  String tempQuery="String_Node_Str";
  String tempRichQuery="String_Node_Str";
  int tempMinSpeed=0;
  Set tempQueryUrns=null;
  Set tempRequestedUrnTypes=null;
  try {
    ByteArrayInputStream bais=new ByteArrayInputStream(this.payload);
    short sp=ByteOrder.leb2short(bais);
    tempMinSpeed=ByteOrder.ubytes2int(sp);
    tempQuery=super.readNullTerminatedString(bais);
    String exts=super.readNullTerminatedString(bais);
    StringTokenizer stok=new StringTokenizer(exts,"String_Node_Str");
    while (stok.hasMoreElements()) {
      String curExtStr=stok.nextToken();
      if (URN.isUrn(curExtStr)) {
        URN urn=null;
        try {
          urn=URN.createSHA1Urn(curExtStr);
        }
 catch (        IOException e) {
          continue;
        }
        if (tempQueryUrns == null) {
          tempQueryUrns=new HashSet();
        }
        tempQueryUrns.add(urn);
        if (tempRequestedUrnTypes == null) {
          tempRequestedUrnTypes=new HashSet();
        }
        tempRequestedUrnTypes.add(urn.getUrnType());
      }
 else       if (UrnType.isSupportedUrnType(curExtStr)) {
        if (tempRequestedUrnTypes == null) {
          tempRequestedUrnTypes=new HashSet();
        }
        tempRequestedUrnTypes.add(curExtStr);
      }
 else       if (curExtStr.startsWith("String_Node_Str")) {
        tempRichQuery=curExtStr;
      }
    }
  }
 catch (  IOException ioe) {
    ioe.printStackTrace();
  }
  query=tempQuery;
  richQuery=tempRichQuery;
  minSpeed=tempMinSpeed;
  if (tempQueryUrns == null) {
    this.queryUrns=EMPTY_SET;
  }
 else {
    this.queryUrns=Collections.unmodifiableSet(tempQueryUrns);
  }
  if (tempRequestedUrnTypes == null) {
    this.requestedUrnTypes=EMPTY_SET;
  }
 else {
    this.requestedUrnTypes=Collections.unmodifiableSet(tempRequestedUrnTypes);
  }
}

Fixed version (ground truth):
/** 
 * Build a new query with data snatched from network
 * @requires payload.length>=3
 */
public QueryRequest(byte[] guid,byte ttl,byte hops,byte[] payload){
  super(guid,Message.F_QUERY,ttl,hops,payload.length);
  if (payload == null) {
    this.payload=EMPTY_BYTE_ARRAY;
  }
 else {
    this.payload=payload;
  }
  String tempQuery="String_Node_Str";
  String tempRichQuery="String_Node_Str";
  int tempMinSpeed=0;
  Set tempQueryUrns=null;
  Set tempRequestedUrnTypes=null;
  try {
    ByteArrayInputStream bais=new ByteArrayInputStream(this.payload);
    short sp=ByteOrder.leb2short(bais);
    tempMinSpeed=ByteOrder.ubytes2int(sp);
    tempQuery=super.readNullTerminatedString(bais);
    String exts=super.readNullTerminatedString(bais);
    StringTokenizer stok=new StringTokenizer(exts,"String_Node_Str");
    while (stok.hasMoreElements()) {
      String curExtStr=stok.nextToken();
      if (URN.isUrn(curExtStr)) {
        URN urn=null;
        try {
          urn=URN.createSHA1Urn(curExtStr);
        }
 catch (        IOException e) {
          continue;
        }
        if (tempQueryUrns == null) {
          tempQueryUrns=new HashSet();
        }
        tempQueryUrns.add(urn);
      }
 else       if (UrnType.isSupportedUrnType(curExtStr)) {
        if (tempRequestedUrnTypes == null) {
          tempRequestedUrnTypes=new HashSet();
        }
        tempRequestedUrnTypes.add(UrnType.createUrnType(curExtStr));
      }
 else       if (curExtStr.startsWith("String_Node_Str")) {
        tempRichQuery=curExtStr;
      }
    }
  }
 catch (  IOException ioe) {
    ioe.printStackTrace();
  }
  query=tempQuery;
  richQuery=tempRichQuery;
  minSpeed=tempMinSpeed;
  if (tempQueryUrns == null) {
    this.queryUrns=EMPTY_SET;
  }
 else {
    this.queryUrns=Collections.unmodifiableSet(tempQueryUrns);
  }
  if (tempRequestedUrnTypes == null) {
    this.requestedUrnTypes=EMPTY_SET;
  }
 else {
    this.requestedUrnTypes=Collections.unmodifiableSet(tempRequestedUrnTypes);
  }
}