aboutsummaryrefslogtreecommitdiff
path: root/fastjar
diff options
context:
space:
mode:
authorAndreas Tobler <a.tobler@schweiz.ch>2004-01-07 19:46:04 +0100
committerAndreas Tobler <andreast@gcc.gnu.org>2004-01-07 19:46:04 +0100
commit6838645e85ed6f8550381f9788f58e42d4f93071 (patch)
treedbb91a8ea2814c973aca1fc43777f0df2ce0c7a7 /fastjar
parent9b773289f883bc57491f8254e7ece335ae948f7e (diff)
downloadgcc-6838645e85ed6f8550381f9788f58e42d4f93071.zip
gcc-6838645e85ed6f8550381f9788f58e42d4f93071.tar.gz
gcc-6838645e85ed6f8550381f9788f58e42d4f93071.tar.bz2
jartool.c (make_manifest): Fix off-by-one bug when creating an empty MANIFEST.MF.
2004-01-07 Andreas Tobler <a.tobler@schweiz.ch> * jartool.c (make_manifest): Fix off-by-one bug when creating an empty MANIFEST.MF. From-SVN: r75511
Diffstat (limited to 'fastjar')
-rw-r--r--fastjar/ChangeLog5
-rw-r--r--fastjar/jartool.c10
2 files changed, 13 insertions, 2 deletions
diff --git a/fastjar/ChangeLog b/fastjar/ChangeLog
index 648a9b6..898d733 100644
--- a/fastjar/ChangeLog
+++ b/fastjar/ChangeLog
@@ -1,3 +1,8 @@
+2004-01-07 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * jartool.c (make_manifest): Fix off-by-one bug when creating
+ an empty MANIFEST.MF.
+
2003-12-01 Kelley Cook <kcook@gcc.gnu.org>
* Makefile.am: Define AM_MAKINFOFLAGS. Remove Automake 1.4 hack.
diff --git a/fastjar/jartool.c b/fastjar/jartool.c
index 83454d2..59e7176 100644
--- a/fastjar/jartool.c
+++ b/fastjar/jartool.c
@@ -313,6 +313,11 @@ int number_of_entries; /* number of entries in the linked list */
/* This holds all options. */
#define OPTION_STRING "-ctxuvVf:m:C:0ME@"
+/* Define the MANIFEST content here to have it easier with calculations
+ below. This is for the case we create an empty MANIFEST.MF. */
+#define MANIFEST_STR "Manifest-Version: 1.0\nCreated-By: "
+#define MANIFEST_END "\n\n"
+
static const struct option options[] =
{
{ "help", no_argument, NULL, OPT_HELP },
@@ -732,13 +737,14 @@ int make_manifest(int jfd, const char *mf_name){
/* if the user didn't specify an external manifest file... */
if(mf_name == NULL){
- int mf_len = 37 + strlen(VERSION);
+
+ int mf_len = strlen(MANIFEST_STR) + strlen(VERSION) + strlen(MANIFEST_END);
char *mf;
if((mf = (char *) malloc(mf_len + 1))) {
uLong crc;
- sprintf(mf, "Manifest-Version: 1.0\nCreated-By: %s\n\n", VERSION);
+ sprintf(mf, "%s%s%s", MANIFEST_STR, VERSION, MANIFEST_END);
crc = crc32(0L, Z_NULL, 0);