Fossil SCM
Use generic hash validity checking in the purge.c module.
Commit
7bd36bc52dca8d524fd235302e3e701f6d939292
Parent
fcc9116a5476cae…
1 file changed
+6
-12
+6
-12
| --- src/purge.c | ||
| +++ src/purge.c | ||
| @@ -347,11 +347,11 @@ | ||
| 347 | 347 | int piid, /* ID of the item to extract */ |
| 348 | 348 | Blob *pOut /* Write the content into this blob */ |
| 349 | 349 | ){ |
| 350 | 350 | Stmt q; |
| 351 | 351 | int srcid; |
| 352 | - Blob h1, h2, x; | |
| 352 | + Blob h1, x; | |
| 353 | 353 | static Bag busy; |
| 354 | 354 | |
| 355 | 355 | db_prepare(&q, "SELECT uuid, srcid, data FROM purgeitem" |
| 356 | 356 | " WHERE piid=%d", piid); |
| 357 | 357 | if( db_step(&q)!=SQLITE_ROW ){ |
| @@ -376,17 +376,14 @@ | ||
| 376 | 376 | blob_reset(&baseline); |
| 377 | 377 | } |
| 378 | 378 | bag_remove(&busy, piid); |
| 379 | 379 | blob_zero(&h1); |
| 380 | 380 | db_column_blob(&q, 0, &h1); |
| 381 | - sha1sum_blob(pOut, &h2); | |
| 382 | - if( blob_compare(&h1, &h2)!=0 ){ | |
| 383 | - fossil_fatal("SHA1 hash mismatch - wanted %s, got %s", | |
| 384 | - blob_str(&h1), blob_str(&h2)); | |
| 381 | + if( hname_verify_hash(pOut, blob_buffer(&h1), blob_size(&h1))==0 ){ | |
| 382 | + fossil_fatal("incorrect artifact hash on %b", &h1); | |
| 385 | 383 | } |
| 386 | 384 | blob_reset(&h1); |
| 387 | - blob_reset(&h2); | |
| 388 | 385 | db_finalize(&q); |
| 389 | 386 | return 0; |
| 390 | 387 | } |
| 391 | 388 | |
| 392 | 389 | /* |
| @@ -411,11 +408,11 @@ | ||
| 411 | 408 | " WHERE ix.srcid=%d" |
| 412 | 409 | " AND ix.piid=purgeitem.piid;", |
| 413 | 410 | iSrc |
| 414 | 411 | ); |
| 415 | 412 | while( db_step(&q)==SQLITE_ROW ){ |
| 416 | - Blob h1, h2, c1, c2; | |
| 413 | + Blob h1, c1, c2; | |
| 417 | 414 | int isPriv, rid; |
| 418 | 415 | blob_zero(&h1); |
| 419 | 416 | db_column_blob(&q, 0, &h1); |
| 420 | 417 | blob_zero(&c1); |
| 421 | 418 | db_column_blob(&q, 1, &c1); |
| @@ -425,16 +422,13 @@ | ||
| 425 | 422 | blob_delta_apply(pBasis, &c1, &c2); |
| 426 | 423 | blob_reset(&c1); |
| 427 | 424 | }else{ |
| 428 | 425 | c2 = c1; |
| 429 | 426 | } |
| 430 | - sha1sum_blob(&c2, &h2); | |
| 431 | - if( blob_compare(&h1, &h2)!=0 ){ | |
| 432 | - fossil_fatal("SHA1 hash mismatch - wanted %s, got %s", | |
| 433 | - blob_str(&h1), blob_str(&h2)); | |
| 427 | + if( hname_verify_hash(&c2, blob_buffer(&h1), blob_size(&h1))==0 ){ | |
| 428 | + fossil_fatal("incorrect hash on %b", &h1); | |
| 434 | 429 | } |
| 435 | - blob_reset(&h2); | |
| 436 | 430 | isPriv = db_column_int(&q, 2); |
| 437 | 431 | rid = content_put_ex(&c2, blob_str(&h1), 0, 0, isPriv); |
| 438 | 432 | if( rid==0 ){ |
| 439 | 433 | fossil_fatal("%s", g.zErrMsg); |
| 440 | 434 | }else{ |
| 441 | 435 |
| --- src/purge.c | |
| +++ src/purge.c | |
| @@ -347,11 +347,11 @@ | |
| 347 | int piid, /* ID of the item to extract */ |
| 348 | Blob *pOut /* Write the content into this blob */ |
| 349 | ){ |
| 350 | Stmt q; |
| 351 | int srcid; |
| 352 | Blob h1, h2, x; |
| 353 | static Bag busy; |
| 354 | |
| 355 | db_prepare(&q, "SELECT uuid, srcid, data FROM purgeitem" |
| 356 | " WHERE piid=%d", piid); |
| 357 | if( db_step(&q)!=SQLITE_ROW ){ |
| @@ -376,17 +376,14 @@ | |
| 376 | blob_reset(&baseline); |
| 377 | } |
| 378 | bag_remove(&busy, piid); |
| 379 | blob_zero(&h1); |
| 380 | db_column_blob(&q, 0, &h1); |
| 381 | sha1sum_blob(pOut, &h2); |
| 382 | if( blob_compare(&h1, &h2)!=0 ){ |
| 383 | fossil_fatal("SHA1 hash mismatch - wanted %s, got %s", |
| 384 | blob_str(&h1), blob_str(&h2)); |
| 385 | } |
| 386 | blob_reset(&h1); |
| 387 | blob_reset(&h2); |
| 388 | db_finalize(&q); |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | /* |
| @@ -411,11 +408,11 @@ | |
| 411 | " WHERE ix.srcid=%d" |
| 412 | " AND ix.piid=purgeitem.piid;", |
| 413 | iSrc |
| 414 | ); |
| 415 | while( db_step(&q)==SQLITE_ROW ){ |
| 416 | Blob h1, h2, c1, c2; |
| 417 | int isPriv, rid; |
| 418 | blob_zero(&h1); |
| 419 | db_column_blob(&q, 0, &h1); |
| 420 | blob_zero(&c1); |
| 421 | db_column_blob(&q, 1, &c1); |
| @@ -425,16 +422,13 @@ | |
| 425 | blob_delta_apply(pBasis, &c1, &c2); |
| 426 | blob_reset(&c1); |
| 427 | }else{ |
| 428 | c2 = c1; |
| 429 | } |
| 430 | sha1sum_blob(&c2, &h2); |
| 431 | if( blob_compare(&h1, &h2)!=0 ){ |
| 432 | fossil_fatal("SHA1 hash mismatch - wanted %s, got %s", |
| 433 | blob_str(&h1), blob_str(&h2)); |
| 434 | } |
| 435 | blob_reset(&h2); |
| 436 | isPriv = db_column_int(&q, 2); |
| 437 | rid = content_put_ex(&c2, blob_str(&h1), 0, 0, isPriv); |
| 438 | if( rid==0 ){ |
| 439 | fossil_fatal("%s", g.zErrMsg); |
| 440 | }else{ |
| 441 |
| --- src/purge.c | |
| +++ src/purge.c | |
| @@ -347,11 +347,11 @@ | |
| 347 | int piid, /* ID of the item to extract */ |
| 348 | Blob *pOut /* Write the content into this blob */ |
| 349 | ){ |
| 350 | Stmt q; |
| 351 | int srcid; |
| 352 | Blob h1, x; |
| 353 | static Bag busy; |
| 354 | |
| 355 | db_prepare(&q, "SELECT uuid, srcid, data FROM purgeitem" |
| 356 | " WHERE piid=%d", piid); |
| 357 | if( db_step(&q)!=SQLITE_ROW ){ |
| @@ -376,17 +376,14 @@ | |
| 376 | blob_reset(&baseline); |
| 377 | } |
| 378 | bag_remove(&busy, piid); |
| 379 | blob_zero(&h1); |
| 380 | db_column_blob(&q, 0, &h1); |
| 381 | if( hname_verify_hash(pOut, blob_buffer(&h1), blob_size(&h1))==0 ){ |
| 382 | fossil_fatal("incorrect artifact hash on %b", &h1); |
| 383 | } |
| 384 | blob_reset(&h1); |
| 385 | db_finalize(&q); |
| 386 | return 0; |
| 387 | } |
| 388 | |
| 389 | /* |
| @@ -411,11 +408,11 @@ | |
| 408 | " WHERE ix.srcid=%d" |
| 409 | " AND ix.piid=purgeitem.piid;", |
| 410 | iSrc |
| 411 | ); |
| 412 | while( db_step(&q)==SQLITE_ROW ){ |
| 413 | Blob h1, c1, c2; |
| 414 | int isPriv, rid; |
| 415 | blob_zero(&h1); |
| 416 | db_column_blob(&q, 0, &h1); |
| 417 | blob_zero(&c1); |
| 418 | db_column_blob(&q, 1, &c1); |
| @@ -425,16 +422,13 @@ | |
| 422 | blob_delta_apply(pBasis, &c1, &c2); |
| 423 | blob_reset(&c1); |
| 424 | }else{ |
| 425 | c2 = c1; |
| 426 | } |
| 427 | if( hname_verify_hash(&c2, blob_buffer(&h1), blob_size(&h1))==0 ){ |
| 428 | fossil_fatal("incorrect hash on %b", &h1); |
| 429 | } |
| 430 | isPriv = db_column_int(&q, 2); |
| 431 | rid = content_put_ex(&c2, blob_str(&h1), 0, 0, isPriv); |
| 432 | if( rid==0 ){ |
| 433 | fossil_fatal("%s", g.zErrMsg); |
| 434 | }else{ |
| 435 |