Fossil SCM
Fix a bug in the manifest parser which caused it to ignore manifests that were signed by a windows-build of PGP.
Commit
696668aa4ec88213cafad039707f49a698e2136c
Parent
d8935a89b51b0f8…
1 file changed
+12
-1
+12
-1
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -184,20 +184,31 @@ | ||
| 184 | 184 | |
| 185 | 185 | #ifdef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM |
| 186 | 186 | # define md5sum_init(X) |
| 187 | 187 | # define md5sum_step_text(X,Y) |
| 188 | 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 | +} | |
| 189 | 200 | |
| 190 | 201 | /* |
| 191 | 202 | ** Remove the PGP signature from the artifact, if there is one. |
| 192 | 203 | */ |
| 193 | 204 | static void remove_pgp_signature(char **pz, int *pn){ |
| 194 | 205 | char *z = *pz; |
| 195 | 206 | int n = *pn; |
| 196 | 207 | int i; |
| 197 | 208 | 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++){} | |
| 199 | 210 | if( i>=n ) return; |
| 200 | 211 | z += i; |
| 201 | 212 | n -= i; |
| 202 | 213 | *pz = z; |
| 203 | 214 | for(i=n-1; i>=0; i--){ |
| 204 | 215 |
| --- 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 |