Program: 64159
Project: 64159
Buggy source:
/** 
 * Get the next entry in this tar archive. This will skip over any remaining data in the current entry, if there is one, and place the input stream at the header of the next entry, and read the header and instantiate a new TarEntry from the header bytes and return that entry. If there are no more entries in the archive, null will be returned to indicate that the end of the archive has been reached.
 * @return The next TarEntry in the archive, or null.
 * @throws IOException on error
 */
public TarEntry getNextEntry() throws IOException {
  if (hasHitEOF) {
    return null;
  }
  if (currEntry != null) {
    long numToSkip=entrySize - entryOffset;
    if (debug) {
      System.err.println("String_Node_Str" + currEntry.getName() + "String_Node_Str"+ entrySize+ "String_Node_Str"+ entryOffset+ "String_Node_Str"+ numToSkip+ "String_Node_Str");
    }
    if (numToSkip > 0) {
      skip(numToSkip);
    }
    readBuf=null;
  }
  byte[] headerBuf=buffer.readRecord();
  if (headerBuf == null) {
    if (debug) {
      System.err.println("String_Node_Str");
    }
    hasHitEOF=true;
  }
 else   if (buffer.isEOFRecord(headerBuf)) {
    if (debug) {
      System.err.println("String_Node_Str");
    }
    hasHitEOF=true;
  }
  if (hasHitEOF) {
    currEntry=null;
  }
 else {
    currEntry=new TarEntry(headerBuf);
    if (debug) {
      System.err.println("String_Node_Str" + currEntry.getName() + "String_Node_Str"+ currEntry.getSize());
    }
    entryOffset=0;
    entrySize=currEntry.getSize();
  }
  if (currEntry != null && currEntry.isGNULongNameEntry()) {
    StringBuffer longName=new StringBuffer();
    byte[] buf=new byte[SMALL_BUFFER_SIZE];
    int length=0;
    while ((length=read(buf)) >= 0) {
      longName.append(new String(buf,0,length));
    }
    getNextEntry();
    if (currEntry == null) {
      return null;
    }
    if (longName.length() > 0 && longName.charAt(longName.length() - 1) == 0) {
      longName.deleteCharAt(longName.length() - 1);
    }
    currEntry.setName(longName.toString());
  }
  return currEntry;
}

Fixed version (ground truth):
/** 
 * Get the next entry in this tar archive. This will skip over any remaining data in the current entry, if there is one, and place the input stream at the header of the next entry, and read the header and instantiate a new TarEntry from the header bytes and return that entry. If there are no more entries in the archive, null will be returned to indicate that the end of the archive has been reached.
 * @return The next TarEntry in the archive, or null.
 * @throws IOException on error
 */
public TarEntry getNextEntry() throws IOException {
  if (hasHitEOF) {
    return null;
  }
  if (currEntry != null) {
    long numToSkip=entrySize - entryOffset;
    if (debug) {
      System.err.println("String_Node_Str" + currEntry.getName() + "String_Node_Str"+ entrySize+ "String_Node_Str"+ entryOffset+ "String_Node_Str"+ numToSkip+ "String_Node_Str");
    }
    while (numToSkip > 0) {
      long skipped=skip(numToSkip);
      if (skipped <= 0) {
        throw new RuntimeException("String_Node_Str" + "String_Node_Str");
      }
      numToSkip-=skipped;
    }
    readBuf=null;
  }
  byte[] headerBuf=buffer.readRecord();
  if (headerBuf == null) {
    if (debug) {
      System.err.println("String_Node_Str");
    }
    hasHitEOF=true;
  }
 else   if (buffer.isEOFRecord(headerBuf)) {
    if (debug) {
      System.err.println("String_Node_Str");
    }
    hasHitEOF=true;
  }
  if (hasHitEOF) {
    currEntry=null;
  }
 else {
    currEntry=new TarEntry(headerBuf);
    if (debug) {
      System.err.println("String_Node_Str" + currEntry.getName() + "String_Node_Str"+ currEntry.getSize());
    }
    entryOffset=0;
    entrySize=currEntry.getSize();
  }
  if (currEntry != null && currEntry.isGNULongNameEntry()) {
    StringBuffer longName=new StringBuffer();
    byte[] buf=new byte[SMALL_BUFFER_SIZE];
    int length=0;
    while ((length=read(buf)) >= 0) {
      longName.append(new String(buf,0,length));
    }
    getNextEntry();
    if (currEntry == null) {
      return null;
    }
    if (longName.length() > 0 && longName.charAt(longName.length() - 1) == 0) {
      longName.deleteCharAt(longName.length() - 1);
    }
    currEntry.setName(longName.toString());
  }
  return currEntry;
}