Fossil SCM
manifest_parse() now stores the UUID before parsing begins and adds it to syntax error messages.
Commit
a87c0d89ae9b617cd6a27d1e245c0a807864c085
Parent
5ff4e336174bbec…
1 file changed
+13
-2
+13
-2
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -254,11 +254,11 @@ | ||
| 254 | 254 | ** value. |
| 255 | 255 | ** |
| 256 | 256 | ** 0123456789 123456789 123456789 123456789 |
| 257 | 257 | ** Z aea84f4f863865a8d59d0384e4d2a41c |
| 258 | 258 | */ |
| 259 | -static int verify_z_card(const char *z, int n){ | |
| 259 | +static int verify_z_card(const char *z, int n ){ | |
| 260 | 260 | if( n<35 ) return 0; |
| 261 | 261 | if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0; |
| 262 | 262 | md5sum_init(); |
| 263 | 263 | md5sum_step_text(z, n-35); |
| 264 | 264 | if( memcmp(&z[n-33], md5sum_finish(0), 32)==0 ){ |
| @@ -360,13 +360,13 @@ | ||
| 360 | 360 | char *z; |
| 361 | 361 | int n; |
| 362 | 362 | char *zUuid; |
| 363 | 363 | int sz = 0; |
| 364 | 364 | int isRepeat, hasSelfRefTag = 0; |
| 365 | + Blob bUuid = BLOB_INITIALIZER; | |
| 365 | 366 | static Bag seen; |
| 366 | 367 | const char *zErr = 0; |
| 367 | - | |
| 368 | 368 | if( rid==0 ){ |
| 369 | 369 | isRepeat = 1; |
| 370 | 370 | }else if( bag_find(&seen, rid) ){ |
| 371 | 371 | isRepeat = 1; |
| 372 | 372 | }else{ |
| @@ -403,10 +403,15 @@ | ||
| 403 | 403 | if( verify_z_card(z, n)==2 ){ |
| 404 | 404 | blob_reset(pContent); |
| 405 | 405 | blob_appendf(pErr, "incorrect Z-card cksum"); |
| 406 | 406 | return 0; |
| 407 | 407 | } |
| 408 | + | |
| 409 | + /* Store the UUID (before modifying the blob) only for error | |
| 410 | + ** reporting purposes. | |
| 411 | + */ | |
| 412 | + sha1sum_blob(pContent, &bUuid); | |
| 408 | 413 | |
| 409 | 414 | /* Allocate a Manifest object to hold the parsed control artifact. |
| 410 | 415 | */ |
| 411 | 416 | p = fossil_malloc( sizeof(*p) ); |
| 412 | 417 | memset(p, 0, sizeof(*p)); |
| @@ -944,13 +949,19 @@ | ||
| 944 | 949 | if( !seenZ ) SYNTAX("missing Z-card on control"); |
| 945 | 950 | p->type = CFTYPE_CONTROL; |
| 946 | 951 | } |
| 947 | 952 | md5sum_init(); |
| 948 | 953 | if( !isRepeat ) g.parseCnt[p->type]++; |
| 954 | + blob_reset(&bUuid); | |
| 949 | 955 | return p; |
| 950 | 956 | |
| 951 | 957 | manifest_syntax_error: |
| 958 | + if(bUuid.nUsed){ | |
| 959 | + blob_appendf(pErr, "manifest UUID %.40s ", | |
| 960 | + blob_str(&bUuid)); | |
| 961 | + blob_reset(&bUuid); | |
| 962 | + } | |
| 952 | 963 | if( zErr ){ |
| 953 | 964 | blob_appendf(pErr, "line %d: %s", lineNo, zErr); |
| 954 | 965 | }else{ |
| 955 | 966 | blob_appendf(pErr, "unknown error on line %d", lineNo); |
| 956 | 967 | } |
| 957 | 968 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -254,11 +254,11 @@ | |
| 254 | ** value. |
| 255 | ** |
| 256 | ** 0123456789 123456789 123456789 123456789 |
| 257 | ** Z aea84f4f863865a8d59d0384e4d2a41c |
| 258 | */ |
| 259 | static int verify_z_card(const char *z, int n){ |
| 260 | if( n<35 ) return 0; |
| 261 | if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0; |
| 262 | md5sum_init(); |
| 263 | md5sum_step_text(z, n-35); |
| 264 | if( memcmp(&z[n-33], md5sum_finish(0), 32)==0 ){ |
| @@ -360,13 +360,13 @@ | |
| 360 | char *z; |
| 361 | int n; |
| 362 | char *zUuid; |
| 363 | int sz = 0; |
| 364 | int isRepeat, hasSelfRefTag = 0; |
| 365 | static Bag seen; |
| 366 | const char *zErr = 0; |
| 367 | |
| 368 | if( rid==0 ){ |
| 369 | isRepeat = 1; |
| 370 | }else if( bag_find(&seen, rid) ){ |
| 371 | isRepeat = 1; |
| 372 | }else{ |
| @@ -403,10 +403,15 @@ | |
| 403 | if( verify_z_card(z, n)==2 ){ |
| 404 | blob_reset(pContent); |
| 405 | blob_appendf(pErr, "incorrect Z-card cksum"); |
| 406 | return 0; |
| 407 | } |
| 408 | |
| 409 | /* Allocate a Manifest object to hold the parsed control artifact. |
| 410 | */ |
| 411 | p = fossil_malloc( sizeof(*p) ); |
| 412 | memset(p, 0, sizeof(*p)); |
| @@ -944,13 +949,19 @@ | |
| 944 | if( !seenZ ) SYNTAX("missing Z-card on control"); |
| 945 | p->type = CFTYPE_CONTROL; |
| 946 | } |
| 947 | md5sum_init(); |
| 948 | if( !isRepeat ) g.parseCnt[p->type]++; |
| 949 | return p; |
| 950 | |
| 951 | manifest_syntax_error: |
| 952 | if( zErr ){ |
| 953 | blob_appendf(pErr, "line %d: %s", lineNo, zErr); |
| 954 | }else{ |
| 955 | blob_appendf(pErr, "unknown error on line %d", lineNo); |
| 956 | } |
| 957 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -254,11 +254,11 @@ | |
| 254 | ** value. |
| 255 | ** |
| 256 | ** 0123456789 123456789 123456789 123456789 |
| 257 | ** Z aea84f4f863865a8d59d0384e4d2a41c |
| 258 | */ |
| 259 | static int verify_z_card(const char *z, int n ){ |
| 260 | if( n<35 ) return 0; |
| 261 | if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0; |
| 262 | md5sum_init(); |
| 263 | md5sum_step_text(z, n-35); |
| 264 | if( memcmp(&z[n-33], md5sum_finish(0), 32)==0 ){ |
| @@ -360,13 +360,13 @@ | |
| 360 | char *z; |
| 361 | int n; |
| 362 | char *zUuid; |
| 363 | int sz = 0; |
| 364 | int isRepeat, hasSelfRefTag = 0; |
| 365 | Blob bUuid = BLOB_INITIALIZER; |
| 366 | static Bag seen; |
| 367 | const char *zErr = 0; |
| 368 | if( rid==0 ){ |
| 369 | isRepeat = 1; |
| 370 | }else if( bag_find(&seen, rid) ){ |
| 371 | isRepeat = 1; |
| 372 | }else{ |
| @@ -403,10 +403,15 @@ | |
| 403 | if( verify_z_card(z, n)==2 ){ |
| 404 | blob_reset(pContent); |
| 405 | blob_appendf(pErr, "incorrect Z-card cksum"); |
| 406 | return 0; |
| 407 | } |
| 408 | |
| 409 | /* Store the UUID (before modifying the blob) only for error |
| 410 | ** reporting purposes. |
| 411 | */ |
| 412 | sha1sum_blob(pContent, &bUuid); |
| 413 | |
| 414 | /* Allocate a Manifest object to hold the parsed control artifact. |
| 415 | */ |
| 416 | p = fossil_malloc( sizeof(*p) ); |
| 417 | memset(p, 0, sizeof(*p)); |
| @@ -944,13 +949,19 @@ | |
| 949 | if( !seenZ ) SYNTAX("missing Z-card on control"); |
| 950 | p->type = CFTYPE_CONTROL; |
| 951 | } |
| 952 | md5sum_init(); |
| 953 | if( !isRepeat ) g.parseCnt[p->type]++; |
| 954 | blob_reset(&bUuid); |
| 955 | return p; |
| 956 | |
| 957 | manifest_syntax_error: |
| 958 | if(bUuid.nUsed){ |
| 959 | blob_appendf(pErr, "manifest UUID %.40s ", |
| 960 | blob_str(&bUuid)); |
| 961 | blob_reset(&bUuid); |
| 962 | } |
| 963 | if( zErr ){ |
| 964 | blob_appendf(pErr, "line %d: %s", lineNo, zErr); |
| 965 | }else{ |
| 966 | blob_appendf(pErr, "unknown error on line %d", lineNo); |
| 967 | } |
| 968 |