[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: MUMmer patches and Artistic license.



In <200907281303.42301.bss@iguanasuicide.net>, Boyd Stephen Smith Jr. wrote:
>In <20090728163525.GC31612@an3as.eu>, Andreas Tille wrote:
>>On Sun, Jul 12, 2009 at 10:50:10PM +0900, Charles Plessy wrote:
>>> > This patch is a good idea -- fixed length buffers are rarely
>>> > considered user-friendly.  However, it is executed poorly; it's not
>>> > ready for upstream in its current state.
>>>
>>> Hi, thank you for the comment.
>>> I will stop to apply this patch until a better solution is found.
>>
>>Quite late comment after working down my batch of unread mail:
>>The patch was *not* *only* to avoid fixed length buffers - it was
>>invented to stop mummer from *crashing*.
>
>I may be able to reply with a corrected patch later today.

Attached is my new patch that removes the errors I saw in the original 
patch.  I welcome any comments on the new patch.

I've also attached a interdiff between the old and new patches for 
reference.

In case anyone feels this work is copyrightable[1], I license my 
contributions under the same license as the original patch.

P.S.  Please CC me if you drop debian-mentors, I am not subscribed to
debian-med.
-- 
Boyd Stephen Smith Jr.           	 ,= ,-_-. =.
bss@iguanasuicide.net            	((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy 	 `-'(. .)`-'
http://iguanasuicide.net/        	     \_/

[1] I don't.
Description: Dynamically allocates space for the strings, instead allocating a predefined size.
Origin: vendor : Debian
Bug: https://sourceforge.net/tracker/?func=detail&aid=1215086&group_id=133157&atid=726404
Index: ./src/tigr/annotate.cc
===================================================================
--- ./src/tigr/annotate.cc
+++ ./src/tigr.orig/annotate.cc
@@ -10,6 +10,7 @@
 */
 
 #include "tigrinc.hh"
+#include <assert.h>
 
 #define  FIELD_LEN  20
 #define  MAX_ALIGN  10000
@@ -138,19 +139,26 @@ void  Show_Alignment (char A [], long in
 //  Print the alignment between strings  A [1 .. M]  and  B [1 .. N] .
 
   {
-   static int  D [MAX_ALIGN] [MAX_ALIGN];
-   static char  Op [MAX_ALIGN] [MAX_ALIGN];
-   static char  Show_A [2 * MAX_ALIGN];
-   static char  Show_B [2 * MAX_ALIGN];
+   int  **D,  *D_buf;
+   char **Op, *Op_buf;
+   char  *Show_A;
+   char  *Show_B;
    int  Errors, Tmp;
    long int  i, j, Ct;
 
-   if  (M >= MAX_ALIGN || N >= MAX_ALIGN)
-       {
-        printf ("\n   *** Too long ***\n\n");
-        fprintf (Gaps_With_Errors_File, "%s %7s\n", Line, "-");
-        return;
-       }
+   assert ( SIZE_MAX / (M+1) >= (N+1) ) ;
+   D_buf  = (int  *) calloc ( (M+1)*(N+1), sizeof(int) ) ;
+   assert ( D_buf ) ;
+   D  = &D_buf ;
+   Op_buf = (char *) calloc ( (M+1)*(N+1), sizeof(char) ) ;
+   assert ( Op_buf ) ;
+   Op = &Op_buf ;
+
+   assert ( SIZE_MAX >> 1 >= (M+1) ) ;
+   Show_A = (char *) calloc ( 2*(M+1) , sizeof(char) ) ;
+   assert ( Show_A ) ;
+   Show_B = (char *) calloc ( 2*(N+1) , sizeof(char) ) ;
+   assert ( Show_B ) ;
 
    D [0] [0] = 0;
    Op [0] [0] = 'a';
@@ -229,5 +237,10 @@ void  Show_Alignment (char A [], long in
       putchar ('\n');
       Ct -= WIDTH;
      }  while  (Ct > 0);
+
+   free ( D_buf ) ;
+   free ( Op_buf ) ;
+   free ( Show_A ) ;
+   free ( Show_B ) ;
    return;
   }
diff -u ./src/tigr/annotate.cc ./src/tigr.orig/annotate.cc
--- ./src/tigr/annotate.cc	2007-11-07 21:47:03.000000000 +0100
+++ ./src/tigr.orig/annotate.cc
@@ -146,12 +146,19 @@
    int  Errors, Tmp;
    long int  i, j, Ct;
 
-   assert ( D_buf  = (int  *) calloc ( (M+1)*(N+1), sizeof(int) ) ) ;
+   assert ( SIZE_MAX / (M+1) >= (N+1) ) ;
+   D_buf  = (int  *) calloc ( (M+1)*(N+1), sizeof(int) ) ;
+   assert ( D_buf ) ;
    D  = &D_buf ;
-   assert ( Op_buf = (char *) calloc ( (M+1)*(N+1), sizeof(char) ) ) ;
+   Op_buf = (char *) calloc ( (M+1)*(N+1), sizeof(char) ) ;
+   assert ( Op_buf ) ;
    Op = &Op_buf ;
-   assert ( Show_A = (char *) calloc ( 2*(M+1) , sizeof(char) ) ) ;
-   assert ( Show_B = (char *) calloc ( 2*(N+1) , sizeof(char) ) ) ;
+
+   assert ( SIZE_MAX >> 1 >= (M+1) ) ;
+   Show_A = (char *) calloc ( 2*(M+1) , sizeof(char) ) ;
+   assert ( Show_A ) ;
+   Show_B = (char *) calloc ( 2*(N+1) , sizeof(char) ) ;
+   assert ( Show_B ) ;
 
    D [0] [0] = 0;
    Op [0] [0] = 'a';

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: