Description: Some apps segfault when non-FASTA data is inputted, and this is flagged as a security
  concern.  I suspect there are still ways to segfault this app, but at least this fixes
  an obvious crash.
  Also fixes https://code.google.com/p/ampliconnoise/issues/detail?id=10
  .
  The package is orphaned upstream, hence not forwarded.
Forwarded: no
Author: Tim Booth
Last-Update: 2013-06-27

--- a/FastaUnique/FastaUnique.c
+++ b/FastaUnique/FastaUnique.c
@@ -39,6 +39,13 @@ void readData(t_Data *ptData, t_Params *
 	nPos = 0;
       }
       else{
+	//If there is no > on first line we're heading for a segfault.
+	if(! ptData->nSeq)
+	{
+	    fprintf(stderr, "File %s does not appear to be in FASTA format.\n", ptParams->szInputFile);
+	    exit(EXIT_FAILURE);
+	}
+
 	i = 0;
 	while(strrchr(szSequence,szLine[i]) != NULL){
 	  i++;
@@ -46,6 +53,10 @@ void readData(t_Data *ptData, t_Params *
 	}
       }
     }
+    //Maybe the final sequence was the longest?
+    if(nPos > ptData->nMaxLen){
+      ptData->nMaxLen = nPos;
+    }
 
     fclose(ifp);
   }
--- a/NDist/NDist.c
+++ b/NDist/NDist.c
@@ -654,6 +654,13 @@ void readData(t_Data *ptData, t_Params *
 	nPos = 0;
       }
       else{
+	//If there is no > on first line we're heading for a segfault.
+	if(! ptData->nSeq)
+	{
+	    fprintf(stderr, "File %s does not appear to be in FASTA format.\n", ptParams->szInputFile);
+	    exit(EXIT_FAILURE);
+	}
+
 	i = 0;
 	while(strrchr(szSequence,szLine[i]) != NULL){
 	  i++;
@@ -661,6 +668,10 @@ void readData(t_Data *ptData, t_Params *
 	}
       }
     }
+    //Maybe the final sequence was the longest?
+    if(nPos > ptData->nMaxLen){
+	ptData->nMaxLen = nPos;
+    }
 
     fclose(ifp);
   }
--- a/Perseus/Perseus.c
+++ b/Perseus/Perseus.c
@@ -793,6 +793,13 @@ void readData(char* szInputFile, t_Data
 	nPos = 0;
       }
       else{
+	//If there is no > on first line we're heading for a segfault.
+	if(! ptData->nSeq)
+	{
+	    fprintf(stderr, "File %s does not appear to be in FASTA format.\n", szInputFile);
+	    exit(EXIT_FAILURE);
+	}
+
 	i = 0;
 	while(strrchr(szSequence,szLine[i]) != NULL){
 	  i++;
@@ -800,6 +807,10 @@ void readData(char* szInputFile, t_Data
 	}
       }
     }
+    //Maybe the final sequence was the longest?
+    if(nPos > ptData->nMaxLen){
+      ptData->nMaxLen = nPos;
+    }
 
     fclose(ifp);
   }
--- a/PerseusD/PerseusD.c
+++ b/PerseusD/PerseusD.c
@@ -844,6 +844,13 @@ void readData(char* szInputFile, t_Data
 	nPos = 0;
       }
       else{
+	//If there is no > on first line we're heading for a segfault.
+	if(! ptData->nSeq)
+	{
+	    fprintf(stderr, "File %s does not appear to be in FASTA format.\n", szInputFile);
+	    exit(EXIT_FAILURE);
+	}
+
 	i = 0;
 	while(strrchr(szSequence,szLine[i]) != NULL){
 	  i++;
@@ -851,6 +858,10 @@ void readData(char* szInputFile, t_Data
 	}
       }
     }
+    //Maybe the final sequence was the longest?
+    if(nPos > ptData->nMaxLen){
+      ptData->nMaxLen = nPos;
+    }
 
     fclose(ifp);
   }
--- a/SeqDist/SeqDist.c
+++ b/SeqDist/SeqDist.c
@@ -799,6 +799,13 @@ void readData(t_Data *ptData, t_Params *
 	nPos = 0;
       }
       else{
+	//If there is no > on first line we're heading for a segfault.
+	if(! ptData->nSeq)
+	{
+	    fprintf(stderr, "File %s does not appear to be in FASTA format.\n", ptParams->szInputFile);
+	    exit(EXIT_FAILURE);
+	}
+
 	i = 0;
 	while(strrchr(szSequence,szLine[i]) != NULL){
 	  i++;
@@ -806,6 +813,10 @@ void readData(t_Data *ptData, t_Params *
 	}
       }
     }
+    //Maybe the final sequence was the longest?
+    if(nPos > ptData->nMaxLen){
+      ptData->nMaxLen = nPos;
+    }
 
     fclose(ifp);
   }
--- a/SeqNoise/SeqNoise.c
+++ b/SeqNoise/SeqNoise.c
@@ -571,6 +571,13 @@ void readData(t_Data *ptData, t_Params *
 	nPos = 0;
       }
       else{
+	//If there is no > on first line we're heading for a segfault.
+	if(! ptData->nSeq)
+	{
+	    fprintf(stderr, "File %s does not appear to be in FASTA format.\n", ptParams->szDataFile);
+	    exit(EXIT_FAILURE);
+	}
+
 	i = 0;
 	while(strrchr(szSequence,szLine[i]) != NULL){
 	  i++;
@@ -578,6 +585,10 @@ void readData(t_Data *ptData, t_Params *
 	}
       }
     }
+    //Maybe the final sequence was the longest?
+    if(nPos > ptData->nMaxLen){
+      ptData->nMaxLen = nPos;
+    }
 
     fclose(ifp);
   }
