File: fix-segfault-on-non-fasta-input.patch

package info (click to toggle)
ampliconnoise 1.29-16
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,316 kB
  • sloc: ansic: 18,085; sh: 2,901; perl: 2,089; makefile: 240
file content (172 lines) | stat: -rw-r--r-- 4,346 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
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);
   }