Touch checks for bad input

Index: Touch.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Touch.java,v
retrieving revision 1.6
diff -u -r1.6 Touch.java
--- Touch.java  2001/03/19 13:05:45     1.6
+++ Touch.java  2001/03/24 00:57:57
@@ -114,6 +114,9 @@
                 Project.MSG_WARN);
             return;
         }
+        if (file.exists() && !file.canWrite()) {
+            throw new BuildException("Can not change modification
date of read-only file " + file);
+        }
         
         if (dateTime != null) {
             DateFormat df =
DateFormat.getDateTimeInstance(DateFormat.SHORT,
@@ -121,6 +124,9 @@

Locale.US);
             try {
                 setMillis(df.parse(dateTime).getTime());
+                if (millis < 0) {
+                    throw new BuildException("Date of " + dateTime +
" results in negative milliseconds value relative to epoch (January 1,
1970, 00:00:00 GMT).");
+                }
             } catch (ParseException pe) {
                 throw new BuildException(pe.getMessage(), pe,
location);
             }

Reply via email to