Fossil SCM

Fix a bug in the manifest parser which caused it to ignore manifests that were signed by a windows-build of PGP.

drh 2010-11-08 20:01 trunk
Commit 696668aa4ec88213cafad039707f49a698e2136c
1 file changed +12 -1
+12 -1
--- src/manifest.c
+++ src/manifest.c
@@ -184,20 +184,31 @@
184184
185185
#ifdef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM
186186
# define md5sum_init(X)
187187
# define md5sum_step_text(X,Y)
188188
#endif
189
+
190
+/*
191
+** Return true if z points to the first character after a blank line.
192
+** Tolerate either \r\n or \n line endings.
193
+*/
194
+static int after_blank_line(const char *z){
195
+ if( z[-1]!='\n' ) return 0;
196
+ if( z[-2]=='\n' ) return 1;
197
+ if( z[-2]=='\r' && z[-3]=='\n' ) return 1;
198
+ return 0;
199
+}
189200
190201
/*
191202
** Remove the PGP signature from the artifact, if there is one.
192203
*/
193204
static void remove_pgp_signature(char **pz, int *pn){
194205
char *z = *pz;
195206
int n = *pn;
196207
int i;
197208
if( memcmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
198
- for(i=34; i<n && (z[i-1]!='\n' || z[i-2]!='\n'); i++){}
209
+ for(i=34; i<n && !after_blank_line(z+i); i++){}
199210
if( i>=n ) return;
200211
z += i;
201212
n -= i;
202213
*pz = z;
203214
for(i=n-1; i>=0; i--){
204215
--- src/manifest.c
+++ src/manifest.c
@@ -184,20 +184,31 @@
184
185 #ifdef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM
186 # define md5sum_init(X)
187 # define md5sum_step_text(X,Y)
188 #endif
 
 
 
 
 
 
 
 
 
 
 
189
190 /*
191 ** Remove the PGP signature from the artifact, if there is one.
192 */
193 static void remove_pgp_signature(char **pz, int *pn){
194 char *z = *pz;
195 int n = *pn;
196 int i;
197 if( memcmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
198 for(i=34; i<n && (z[i-1]!='\n' || z[i-2]!='\n'); i++){}
199 if( i>=n ) return;
200 z += i;
201 n -= i;
202 *pz = z;
203 for(i=n-1; i>=0; i--){
204
--- src/manifest.c
+++ src/manifest.c
@@ -184,20 +184,31 @@
184
185 #ifdef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM
186 # define md5sum_init(X)
187 # define md5sum_step_text(X,Y)
188 #endif
189
190 /*
191 ** Return true if z points to the first character after a blank line.
192 ** Tolerate either \r\n or \n line endings.
193 */
194 static int after_blank_line(const char *z){
195 if( z[-1]!='\n' ) return 0;
196 if( z[-2]=='\n' ) return 1;
197 if( z[-2]=='\r' && z[-3]=='\n' ) return 1;
198 return 0;
199 }
200
201 /*
202 ** Remove the PGP signature from the artifact, if there is one.
203 */
204 static void remove_pgp_signature(char **pz, int *pn){
205 char *z = *pz;
206 int n = *pn;
207 int i;
208 if( memcmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
209 for(i=34; i<n && !after_blank_line(z+i); i++){}
210 if( i>=n ) return;
211 z += i;
212 n -= i;
213 *pz = z;
214 for(i=n-1; i>=0; i--){
215

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button