This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug target/38326] [4.3/4.4 regression] libjava build failure on ia64-linux-gnu



------- Comment #10 from jakub at gcc dot gnu dot org  2009-01-09 14:30 -------
This is an obvious bug in fastjar-0.97:

ub4
unix2dostime (time_t *unix_time)
{
  struct tm *ltime = localtime (unix_time);
  int year = ltime->tm_year - 80;
...
}

int make_manifest(int jfd, const char *mf_name, int updating)
{
  time_t current_time;
  size_t nlen;   /* length of file name */
  int mod_time; /* file modification time */
  struct zipentry *ze;

  mod_time = unix2dostime(&current_time);

  /* If we are creating a new manifest, create a META-INF directory entry */
  if (0 == updating) {
    nlen = 9;  /* trust me on this one */

    memset((file_header + 12), '\0', 16); /*clear mod time, crc, size fields*/

    current_time = time(NULL);
    if(current_time == (time_t)-1)
      exit_on_error("time");
...

current_time is uninitialized when calling unix2dostime and depending on what
kind of garbage it contains, localtime either returns some randomly filled
struct tm pointer, or NULL.  If it returns NULL (and it doesn't bother checking
for non-NULL returned value), it segfaults.

fastjar-0.96 and earlier in make_manifest always did current_time = time
(NULL);
etc. before calling unix2dostime.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38326


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