8013506: Better Pack200 data handling
authorksrini
Tue, 07 May 2013 13:37:03 -0700
changeset 20797 bb3ea44a7875
parent 20796 ba811c58b250
child 20798 d03e6abc2b51
8013506: Better Pack200 data handling Reviewed-by: jrose, kizune, mschoene
jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp	Tue Apr 23 09:37:31 2013 +0200
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp	Tue May 07 13:37:03 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -340,6 +340,10 @@
   struct tm sbuf;
   (void)memset((void*)&sbuf,0, sizeof(sbuf));
   struct tm* s = gmtime_r(&t, &sbuf);
+  if (s == NULL) {
+    fprintf(u->errstrm, "Error: gmtime failure, invalid input archive\n");
+    exit(2);
+  }
   modtime_cache = modtime;
   dostime_cache = dostime(s->tm_year + 1900, s->tm_mon + 1, s->tm_mday,
                           s->tm_hour, s->tm_min, s->tm_sec);
@@ -384,7 +388,7 @@
   }
 
   deflated.empty();
-  zs.next_out  = (uchar*) deflated.grow(len + (len/2));
+  zs.next_out  = (uchar*) deflated.grow(add_size(len, (len/2)));
   zs.avail_out = (int)deflated.size();
 
   zs.next_in = (uchar*)head.ptr;