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] fastjar fix off-by one bug.


Hi,

the patch below fixes a off-by-one bug in the jartool when we create an empty MANIFEST.MF.

Ok for main?

Thanks,

Andreas


2004-01-06 Andreas Tobler <a.tobler@schweiz.ch>


	* jartool.c (make_manifest): Fix off-by-one bug when creating
	an empty MANIFEST.MF.

Index: jartool.c
===================================================================
RCS file: /cvs/gcc/gcc/fastjar/jartool.c,v
retrieving revision 1.24
diff -u -r1.24 jartool.c
--- jartool.c   2 Jul 2003 17:20:54 -0000       1.24
+++ jartool.c   6 Jan 2004 06:05:48 -0000
@@ -313,6 +313,12 @@
 /* This holds all options.  */
 #define OPTION_STRING "-ctxuvVf:m:C:0ME@"

+/* This defines the length of the following string:
+   "Manifest-Version: 1.0\nCreated-By: %s\n\n".
+   The \n is counted as one character and the %s isn't counted.
+   The version string length is added below.  */
+#define MANIFEST_STR_LENGTH 36
+
 static const struct option options[] =
 {
   { "help", no_argument, NULL, OPT_HELP },
@@ -732,7 +738,8 @@

   /* if the user didn't specify an external manifest file... */
   if(mf_name == NULL){
-    int mf_len = 37 + strlen(VERSION);
+
+    int mf_len = MANIFEST_STR_LENGTH + strlen(VERSION);
     char *mf;

if((mf = (char *) malloc(mf_len + 1))) {


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