Fossil SCM
Remove references to SHA1 hashing from the structural artifact parser.
Commit
9f17d77ada4dc66b16b1a3512c0868dc3bb3e536
Parent
ac279fa0190cd91…
1 file changed
+16
-19
+16
-19
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -327,26 +327,27 @@ | ||
| 327 | 327 | ** takes over the input blob and will free it when the |
| 328 | 328 | ** Manifest object is freed. Zeros are inserted into the blob |
| 329 | 329 | ** as string terminators so that blob should not be used again. |
| 330 | 330 | ** |
| 331 | 331 | ** Return a pointer to an allocated Manifest object if the content |
| 332 | -** really is a control file of some kind. This object needs to be | |
| 333 | -** freed by a subsequent call to manifest_destroy(). Return NULL | |
| 334 | -** if there are syntax errors. | |
| 332 | +** really is a structural artifact of some kind. The returned Manifest | |
| 333 | +** object needs to be freed by a subsequent call to manifest_destroy(). | |
| 334 | +** Return NULL if there are syntax errors or if the input blob does | |
| 335 | +** not describe a valid structural artifact. | |
| 335 | 336 | ** |
| 336 | -** This routine is strict about the format of a control file. | |
| 337 | +** This routine is strict about the format of a structural artifacts. | |
| 337 | 338 | ** The format must match exactly or else it is rejected. This |
| 338 | -** rule minimizes the risk that a content file will be mistaken | |
| 339 | -** for a control file simply because they look the same. | |
| 339 | +** rule minimizes the risk that a content artifact will be mistaken | |
| 340 | +** for a structural artifact simply because they look the same. | |
| 340 | 341 | ** |
| 341 | 342 | ** The pContent is reset. If a pointer is returned, then pContent will |
| 342 | 343 | ** be reset when the Manifest object is cleared. If NULL is |
| 343 | 344 | ** returned then the Manifest object is cleared automatically |
| 344 | 345 | ** and pContent is reset before the return. |
| 345 | 346 | ** |
| 346 | -** The entire file can be PGP clear-signed. The signature is ignored. | |
| 347 | -** The file consists of zero or more cards, one card per line. | |
| 347 | +** The entire input blob can be PGP clear-signed. The signature is ignored. | |
| 348 | +** The artifact consists of zero or more cards, one card per line. | |
| 348 | 349 | ** (Except: the content of the W card can extend of multiple lines.) |
| 349 | 350 | ** Each card is divided into tokens by a single space character. |
| 350 | 351 | ** The first token is a single upper-case letter which is the card type. |
| 351 | 352 | ** The card type determines the other parameters to the card. |
| 352 | 353 | ** Cards must occur in lexicographical order. |
| @@ -361,11 +362,10 @@ | ||
| 361 | 362 | char *z; |
| 362 | 363 | int n; |
| 363 | 364 | char *zUuid; |
| 364 | 365 | int sz = 0; |
| 365 | 366 | int isRepeat, hasSelfRefTag = 0; |
| 366 | - Blob bHname = BLOB_INITIALIZER; | |
| 367 | 367 | static Bag seen; |
| 368 | 368 | const char *zErr = 0; |
| 369 | 369 | |
| 370 | 370 | if( rid==0 ){ |
| 371 | 371 | isRepeat = 1; |
| @@ -374,11 +374,11 @@ | ||
| 374 | 374 | }else{ |
| 375 | 375 | isRepeat = 0; |
| 376 | 376 | bag_insert(&seen, rid); |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - /* Every control artifact ends with a '\n' character. Exit early | |
| 379 | + /* Every structural artifact ends with a '\n' character. Exit early | |
| 380 | 380 | ** if that is not the case for this artifact. |
| 381 | 381 | */ |
| 382 | 382 | if( !isRepeat ) g.parseCnt[0]++; |
| 383 | 383 | z = blob_materialize(pContent); |
| 384 | 384 | n = blob_size(pContent); |
| @@ -406,15 +406,10 @@ | ||
| 406 | 406 | blob_reset(pContent); |
| 407 | 407 | blob_appendf(pErr, "incorrect Z-card cksum"); |
| 408 | 408 | return 0; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - /* Store the artifact hash (before modifying the blob) only for error | |
| 412 | - ** reporting purposes. | |
| 413 | - */ | |
| 414 | - sha1sum_blob(pContent, &bHname); | |
| 415 | - | |
| 416 | 411 | /* Allocate a Manifest object to hold the parsed control artifact. |
| 417 | 412 | */ |
| 418 | 413 | p = fossil_malloc( sizeof(*p) ); |
| 419 | 414 | memset(p, 0, sizeof(*p)); |
| 420 | 415 | memcpy(&p->content, pContent, sizeof(p->content)); |
| @@ -950,17 +945,19 @@ | ||
| 950 | 945 | if( !seenZ ) SYNTAX("missing Z-card on control"); |
| 951 | 946 | p->type = CFTYPE_CONTROL; |
| 952 | 947 | } |
| 953 | 948 | md5sum_init(); |
| 954 | 949 | if( !isRepeat ) g.parseCnt[p->type]++; |
| 955 | - blob_reset(&bHname); | |
| 956 | 950 | return p; |
| 957 | 951 | |
| 958 | 952 | manifest_syntax_error: |
| 959 | - if(bHname.nUsed){ | |
| 960 | - blob_appendf(pErr, "manifest [%s] ", blob_str(&bHname)); | |
| 961 | - blob_reset(&bHname); | |
| 953 | + { | |
| 954 | + char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); | |
| 955 | + if( zUuid ){ | |
| 956 | + blob_appendf(pErr, "manifest [%s] ", zUuid); | |
| 957 | + fossil_free(zUuid); | |
| 958 | + } | |
| 962 | 959 | } |
| 963 | 960 | if( zErr ){ |
| 964 | 961 | blob_appendf(pErr, "line %d: %s", lineNo, zErr); |
| 965 | 962 | }else{ |
| 966 | 963 | blob_appendf(pErr, "unknown error on line %d", lineNo); |
| 967 | 964 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -327,26 +327,27 @@ | |
| 327 | ** takes over the input blob and will free it when the |
| 328 | ** Manifest object is freed. Zeros are inserted into the blob |
| 329 | ** as string terminators so that blob should not be used again. |
| 330 | ** |
| 331 | ** Return a pointer to an allocated Manifest object if the content |
| 332 | ** really is a control file of some kind. This object needs to be |
| 333 | ** freed by a subsequent call to manifest_destroy(). Return NULL |
| 334 | ** if there are syntax errors. |
| 335 | ** |
| 336 | ** This routine is strict about the format of a control file. |
| 337 | ** The format must match exactly or else it is rejected. This |
| 338 | ** rule minimizes the risk that a content file will be mistaken |
| 339 | ** for a control file simply because they look the same. |
| 340 | ** |
| 341 | ** The pContent is reset. If a pointer is returned, then pContent will |
| 342 | ** be reset when the Manifest object is cleared. If NULL is |
| 343 | ** returned then the Manifest object is cleared automatically |
| 344 | ** and pContent is reset before the return. |
| 345 | ** |
| 346 | ** The entire file can be PGP clear-signed. The signature is ignored. |
| 347 | ** The file consists of zero or more cards, one card per line. |
| 348 | ** (Except: the content of the W card can extend of multiple lines.) |
| 349 | ** Each card is divided into tokens by a single space character. |
| 350 | ** The first token is a single upper-case letter which is the card type. |
| 351 | ** The card type determines the other parameters to the card. |
| 352 | ** Cards must occur in lexicographical order. |
| @@ -361,11 +362,10 @@ | |
| 361 | char *z; |
| 362 | int n; |
| 363 | char *zUuid; |
| 364 | int sz = 0; |
| 365 | int isRepeat, hasSelfRefTag = 0; |
| 366 | Blob bHname = BLOB_INITIALIZER; |
| 367 | static Bag seen; |
| 368 | const char *zErr = 0; |
| 369 | |
| 370 | if( rid==0 ){ |
| 371 | isRepeat = 1; |
| @@ -374,11 +374,11 @@ | |
| 374 | }else{ |
| 375 | isRepeat = 0; |
| 376 | bag_insert(&seen, rid); |
| 377 | } |
| 378 | |
| 379 | /* Every control artifact ends with a '\n' character. Exit early |
| 380 | ** if that is not the case for this artifact. |
| 381 | */ |
| 382 | if( !isRepeat ) g.parseCnt[0]++; |
| 383 | z = blob_materialize(pContent); |
| 384 | n = blob_size(pContent); |
| @@ -406,15 +406,10 @@ | |
| 406 | blob_reset(pContent); |
| 407 | blob_appendf(pErr, "incorrect Z-card cksum"); |
| 408 | return 0; |
| 409 | } |
| 410 | |
| 411 | /* Store the artifact hash (before modifying the blob) only for error |
| 412 | ** reporting purposes. |
| 413 | */ |
| 414 | sha1sum_blob(pContent, &bHname); |
| 415 | |
| 416 | /* Allocate a Manifest object to hold the parsed control artifact. |
| 417 | */ |
| 418 | p = fossil_malloc( sizeof(*p) ); |
| 419 | memset(p, 0, sizeof(*p)); |
| 420 | memcpy(&p->content, pContent, sizeof(p->content)); |
| @@ -950,17 +945,19 @@ | |
| 950 | if( !seenZ ) SYNTAX("missing Z-card on control"); |
| 951 | p->type = CFTYPE_CONTROL; |
| 952 | } |
| 953 | md5sum_init(); |
| 954 | if( !isRepeat ) g.parseCnt[p->type]++; |
| 955 | blob_reset(&bHname); |
| 956 | return p; |
| 957 | |
| 958 | manifest_syntax_error: |
| 959 | if(bHname.nUsed){ |
| 960 | blob_appendf(pErr, "manifest [%s] ", blob_str(&bHname)); |
| 961 | blob_reset(&bHname); |
| 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 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -327,26 +327,27 @@ | |
| 327 | ** takes over the input blob and will free it when the |
| 328 | ** Manifest object is freed. Zeros are inserted into the blob |
| 329 | ** as string terminators so that blob should not be used again. |
| 330 | ** |
| 331 | ** Return a pointer to an allocated Manifest object if the content |
| 332 | ** really is a structural artifact of some kind. The returned Manifest |
| 333 | ** object needs to be freed by a subsequent call to manifest_destroy(). |
| 334 | ** Return NULL if there are syntax errors or if the input blob does |
| 335 | ** not describe a valid structural artifact. |
| 336 | ** |
| 337 | ** This routine is strict about the format of a structural artifacts. |
| 338 | ** The format must match exactly or else it is rejected. This |
| 339 | ** rule minimizes the risk that a content artifact will be mistaken |
| 340 | ** for a structural artifact simply because they look the same. |
| 341 | ** |
| 342 | ** The pContent is reset. If a pointer is returned, then pContent will |
| 343 | ** be reset when the Manifest object is cleared. If NULL is |
| 344 | ** returned then the Manifest object is cleared automatically |
| 345 | ** and pContent is reset before the return. |
| 346 | ** |
| 347 | ** The entire input blob can be PGP clear-signed. The signature is ignored. |
| 348 | ** The artifact consists of zero or more cards, one card per line. |
| 349 | ** (Except: the content of the W card can extend of multiple lines.) |
| 350 | ** Each card is divided into tokens by a single space character. |
| 351 | ** The first token is a single upper-case letter which is the card type. |
| 352 | ** The card type determines the other parameters to the card. |
| 353 | ** Cards must occur in lexicographical order. |
| @@ -361,11 +362,10 @@ | |
| 362 | char *z; |
| 363 | int n; |
| 364 | char *zUuid; |
| 365 | int sz = 0; |
| 366 | int isRepeat, hasSelfRefTag = 0; |
| 367 | static Bag seen; |
| 368 | const char *zErr = 0; |
| 369 | |
| 370 | if( rid==0 ){ |
| 371 | isRepeat = 1; |
| @@ -374,11 +374,11 @@ | |
| 374 | }else{ |
| 375 | isRepeat = 0; |
| 376 | bag_insert(&seen, rid); |
| 377 | } |
| 378 | |
| 379 | /* Every structural artifact ends with a '\n' character. Exit early |
| 380 | ** if that is not the case for this artifact. |
| 381 | */ |
| 382 | if( !isRepeat ) g.parseCnt[0]++; |
| 383 | z = blob_materialize(pContent); |
| 384 | n = blob_size(pContent); |
| @@ -406,15 +406,10 @@ | |
| 406 | blob_reset(pContent); |
| 407 | blob_appendf(pErr, "incorrect Z-card cksum"); |
| 408 | return 0; |
| 409 | } |
| 410 | |
| 411 | /* Allocate a Manifest object to hold the parsed control artifact. |
| 412 | */ |
| 413 | p = fossil_malloc( sizeof(*p) ); |
| 414 | memset(p, 0, sizeof(*p)); |
| 415 | memcpy(&p->content, pContent, sizeof(p->content)); |
| @@ -950,17 +945,19 @@ | |
| 945 | if( !seenZ ) SYNTAX("missing Z-card on control"); |
| 946 | p->type = CFTYPE_CONTROL; |
| 947 | } |
| 948 | md5sum_init(); |
| 949 | if( !isRepeat ) g.parseCnt[p->type]++; |
| 950 | return p; |
| 951 | |
| 952 | manifest_syntax_error: |
| 953 | { |
| 954 | char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 955 | if( zUuid ){ |
| 956 | blob_appendf(pErr, "manifest [%s] ", zUuid); |
| 957 | fossil_free(zUuid); |
| 958 | } |
| 959 | } |
| 960 | if( zErr ){ |
| 961 | blob_appendf(pErr, "line %d: %s", lineNo, zErr); |
| 962 | }else{ |
| 963 | blob_appendf(pErr, "unknown error on line %d", lineNo); |
| 964 |