This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: jartool.c and formatted time string in JAR listings


Hi,

    The jar tool's listing of an archive's contents has a small
bug: if the formatted time string fills out all the available
buffer space, the string is not '\0' terminated - neither
by strftime( ) nor by jartool.

On my machine, Win98/MSVCRT expands "%Z" to "India Standard Time"
instead of "IST" as Linux/glibc does. This results in funny
characters being printed in the jar listing and the layout
is all messed up.

This patch proposes to fix this.

ChangeLog:

2003-01-20  Ranjit Mathew  <rmathew@hotmail.com>

        * jartool.c (list_jar): Terminate the 'ascii_date' buffer
        with a '\0' to guard against the case where the formatted
        time string is more than the size allowed by the buffer.

Patch:
-------------------------- 8< --------------------------
--- jartool.c	Mon Jan 20 23:27:56 2003
+++ jartool.c	Mon Jan 20 23:31:42 2003
@@ -1572,5 +1572,5 @@
   time_t tdate;
   struct tm *s_tm;
-  char ascii_date[30];
+  char ascii_date[31];
   zipentry ze;

@@ -1663,4 +1663,5 @@
         s_tm = localtime(&tdate);
         strftime(ascii_date, 30, "%a %b %d %H:%M:%S %Z %Y", s_tm);
+        ascii_date[30] = '\0';
       }

@@ -1782,4 +1783,5 @@
         s_tm = localtime(&tdate);
         strftime(ascii_date, 30, "%a %b %d %H:%M:%S %Z %Y", s_tm);
+        ascii_date[30] = '\0';
       }

-------------------------- 8< --------------------------

Sincerely Yours,
Ranjit.

--
Ranjit Mathew        Email: rmathew AT hotmail DOT com
Bangalore,
INDIA.               Web: http://ranjitmathew.tripod.com/



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]