/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Borrowing significantly from Martin Buchholz's CorruptedZipFiles.java
*
* inflate_file from file j2se/src/share/bin/parse_manifest.c
* and running them with the 64-bit launcher. e.g.
*
* Run from a script driver Test6842838.sh as we want to specifically run
*
* So this program will create a zip file and damage it in the way
* required to tickle this bug.
*
* It will cause a buffer overrun: but that will not always crash.
* Use libumem preloaded by the script driver in order to
* abort quickly when the overrun happens. That makes the test
* Solaris-specific.
*/
public class CreateBadJar {
throw new RuntimeException("Arguments: jarfilename entryname");
}
try {
// If the named file doesn't exist, create it.
// If it does, we are expecting it to contain the named entry, for
// alteration.
zos = new ZipOutputStream(
new FileOutputStream(outFile));
zos.putNextEntry(e);
for (int j=0; j<50000; j++) {
}
zos.closeEntry();
}
// Read it.
byte[] bad;
// Corrupt it...
// What bad stuff are we doing to it?
// Store a 32-bit -1 in uncomp size.
// Bad work complete, delete the original.
// Write it.
} catch (Exception e) {
e.printStackTrace();
}
}
/*
* Scan Central Directory File Headers looking for the named entry.
*/
int nextPos = 0;
do {
if (nextPos != 0) {
}
if (u32(bytes, pos) != CENSIG) throw new RuntimeException ("entry not found in CEN or premature end...");
return pos;
}
}
}
}
}