conor 02/05/22 22:37:37
Modified: src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH
LoadFile.java
src/main/org/apache/tools/ant/util Tag: ANT_15_BRANCH
FileUtils.java
Log:
Handle case when load file is zero bytes long.
Change FileUtils to reject zero size buffer requests
PR: 9323
Revision Changes Path
No revision
No revision
1.17.2.1 +11 -8
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/LoadFile.java
Index: LoadFile.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/LoadFile.java,v
retrieving revision 1.17
retrieving revision 1.17.2.1
diff -u -w -u -r1.17 -r1.17.2.1
--- LoadFile.java 15 Apr 2002 13:36:17 -0000 1.17
+++ LoadFile.java 23 May 2002 05:37:37 -0000 1.17.2.1
@@ -182,6 +182,8 @@
instream = new InputStreamReader(bis, encoding);
}
+ String text = "";
+ if (size != 0) {
ChainReaderHelper crh = new ChainReaderHelper();
crh.setBufferSize(size);
crh.setPrimaryReader(instream);
@@ -189,7 +191,8 @@
crh.setProject(project);
instream = crh.getAssembledReader();
- String text = crh.readFully(instream);
+ text = crh.readFully(instream);
+ }
if (text != null) {
project.setNewProperty(property, text);
No revision
No revision
1.25.2.2 +5 -1
jakarta-ant/src/main/org/apache/tools/ant/util/FileUtils.java
Index: FileUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/FileUtils.java,v
retrieving revision 1.25.2.1
retrieving revision 1.25.2.2
diff -u -w -u -r1.25.2.1 -r1.25.2.2
--- FileUtils.java 10 May 2002 12:53:58 -0000 1.25.2.1
+++ FileUtils.java 23 May 2002 05:37:37 -0000 1.25.2.2
@@ -95,7 +95,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Magesh Umasankar</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jeff Tulley</a>
*
- * @version $Revision: 1.25.2.1 $
+ * @version $Revision: 1.25.2.2 $
*/
public class FileUtils {
@@ -781,6 +781,10 @@
* Read from reader till EOF
*/
public static final String readFully(Reader rdr, int bufferSize) throws
IOException {
+ if (bufferSize <= 0) {
+ throw new IllegalArgumentException("Buffer size must be greater
"
+ + "than 0");
+ }
final char[] buffer = new char[bufferSize];
int bufferLength = 0;
String text = null;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>