mirror of
https://github.com/apache/archiva.git
synced 2025-02-21 09:24:54 +00:00
[MRM-1625] java.lang.ArrayIndexOutOfBoundsException from parsing maven-metadata.xml
Submitted by charlie kim. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1327885 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1e79ae0703
commit
037977e426
@ -69,12 +69,13 @@ public int read( char[] destbuf, int offset, int length )
|
||||
{
|
||||
// Copy partial leftover.
|
||||
System.arraycopy( leftover, 0, destbuf, current_requested_offset, length );
|
||||
int copyLeftOverLength = leftover.length - length;
|
||||
|
||||
// Create new leftover of remaining.
|
||||
char tmp[] = new char[length];
|
||||
System.arraycopy( leftover, length, tmp, 0, length );
|
||||
char tmp[] = new char[copyLeftOverLength];
|
||||
System.arraycopy( leftover, length, tmp, 0, copyLeftOverLength );
|
||||
leftover = new char[tmp.length];
|
||||
System.arraycopy( tmp, 0, leftover, 0, length );
|
||||
System.arraycopy( tmp, 0, leftover, 0, copyLeftOverLength );
|
||||
|
||||
// Return len
|
||||
return length;
|
||||
|
@ -23,8 +23,17 @@
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.net.URL;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.io.SAXReader;
|
||||
|
||||
/**
|
||||
* LatinEntityResolutionReaderTest
|
||||
@ -193,6 +202,29 @@ public void testReaderHugeBufsize()
|
||||
assertProperRead( expected, "no-prolog-with-entities.xml", 409600 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testReaderLeftOver()
|
||||
throws IOException
|
||||
{
|
||||
File inputFile = getExampleXml( "maven-metadata-leftover.xml" );
|
||||
//Bits from RepositoryMetadataReader.read
|
||||
InputStream in = null;
|
||||
SAXReader reader = new SAXReader();
|
||||
URL url = inputFile.toURL();
|
||||
in = url.openStream();
|
||||
InputStreamReader inReader = new InputStreamReader( in, "UTF-8" );
|
||||
LatinEntityResolutionReader latinReader = new LatinEntityResolutionReader( inReader );
|
||||
try {
|
||||
reader.read( latinReader );
|
||||
} catch (DocumentException e) {
|
||||
Assert.fail("Should not have failed here." + e);
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testNoLatinEntitiesHugeLine()
|
||||
{
|
||||
assertProperRead( "commons-codec-1.2.pom", "commons-codec-1.2.pom", 4096 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user