Program: 64160
Project: 64160
Buggy source:
/** 
 * Writes bytes to the current tar archive entry. This method is aware of the current entry and will throw an exception if you attempt to write bytes past the length specified for the current entry. The method is also (painfully) aware of the record buffering required by TarBuffer, and manages buffers that are not a multiple of recordsize in length, including assembling records from small buffers.
 * @param wBuf The buffer to write to the archive.
 * @param wOffset The offset in the buffer from which to get bytes.
 * @param numToWrite The number of bytes to write.
 * @throws IOException on error
 */
public void write(byte[] wBuf,int wOffset,int numToWrite) throws IOException {
  if ((currBytes + numToWrite) > currSize) {
    throw new IOException("String_Node_Str" + numToWrite + "String_Node_Str"+ currSize+ "String_Node_Str"+ currName+ "String_Node_Str");
  }
  if (assemLen > 0) {
    if ((assemLen + numToWrite) >= recordBuf.length) {
      int aLen=recordBuf.length - assemLen;
      System.arraycopy(assemBuf,0,recordBuf,0,assemLen);
      System.arraycopy(wBuf,wOffset,recordBuf,assemLen,aLen);
      buffer.writeRecord(recordBuf);
      currBytes+=recordBuf.length;
      wOffset+=aLen;
      numToWrite-=aLen;
      assemLen=0;
    }
 else {
      System.arraycopy(wBuf,wOffset,assemBuf,assemLen,numToWrite);
      wOffset+=numToWrite;
      assemLen+=numToWrite;
      numToWrite-=numToWrite;
    }
  }
  while (numToWrite > 0) {
    if (numToWrite < recordBuf.length) {
      System.arraycopy(wBuf,wOffset,assemBuf,assemLen,numToWrite);
      assemLen+=numToWrite;
      break;
    }
    buffer.writeRecord(wBuf,wOffset);
    int num=recordBuf.length;
    currBytes+=num;
    numToWrite-=num;
    wOffset+=num;
  }
}

Fixed version (ground truth):
/** 
 * Writes bytes to the current tar archive entry. This method is aware of the current entry and will throw an exception if you attempt to write bytes past the length specified for the current entry. The method is also (painfully) aware of the record buffering required by TarBuffer, and manages buffers that are not a multiple of recordsize in length, including assembling records from small buffers.
 * @param wBuf The buffer to write to the archive.
 * @param wOffset The offset in the buffer from which to get bytes.
 * @param numToWrite The number of bytes to write.
 * @throws IOException on error
 */
public void write(byte[] wBuf,int wOffset,int numToWrite) throws IOException {
  if ((currBytes + numToWrite) > currSize) {
    throw new IOException("String_Node_Str" + numToWrite + "String_Node_Str"+ currSize+ "String_Node_Str"+ currName+ "String_Node_Str");
  }
  if (assemLen > 0) {
    if ((assemLen + numToWrite) >= recordBuf.length) {
      int aLen=recordBuf.length - assemLen;
      System.arraycopy(assemBuf,0,recordBuf,0,assemLen);
      System.arraycopy(wBuf,wOffset,recordBuf,assemLen,aLen);
      buffer.writeRecord(recordBuf);
      currBytes+=recordBuf.length;
      wOffset+=aLen;
      numToWrite-=aLen;
      assemLen=0;
    }
 else {
      System.arraycopy(wBuf,wOffset,assemBuf,assemLen,numToWrite);
      wOffset+=numToWrite;
      assemLen+=numToWrite;
      numToWrite=0;
    }
  }
  while (numToWrite > 0) {
    if (numToWrite < recordBuf.length) {
      System.arraycopy(wBuf,wOffset,assemBuf,assemLen,numToWrite);
      assemLen+=numToWrite;
      break;
    }
    buffer.writeRecord(wBuf,wOffset);
    int num=recordBuf.length;
    currBytes+=num;
    numToWrite-=num;
    wOffset+=num;
  }
}