Fossil SCM

Remove references to SHA1 hashing from the structural artifact parser.

drh 2017-02-28 20:28 fossil-2.0
Commit 9f17d77ada4dc66b16b1a3512c0868dc3bb3e536
1 file changed +16 -19
+16 -19
--- src/manifest.c
+++ src/manifest.c
@@ -327,26 +327,27 @@
327327
** takes over the input blob and will free it when the
328328
** Manifest object is freed. Zeros are inserted into the blob
329329
** as string terminators so that blob should not be used again.
330330
**
331331
** 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.
335336
**
336
-** This routine is strict about the format of a control file.
337
+** This routine is strict about the format of a structural artifacts.
337338
** 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.
340341
**
341342
** The pContent is reset. If a pointer is returned, then pContent will
342343
** be reset when the Manifest object is cleared. If NULL is
343344
** returned then the Manifest object is cleared automatically
344345
** and pContent is reset before the return.
345346
**
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.
348349
** (Except: the content of the W card can extend of multiple lines.)
349350
** Each card is divided into tokens by a single space character.
350351
** The first token is a single upper-case letter which is the card type.
351352
** The card type determines the other parameters to the card.
352353
** Cards must occur in lexicographical order.
@@ -361,11 +362,10 @@
361362
char *z;
362363
int n;
363364
char *zUuid;
364365
int sz = 0;
365366
int isRepeat, hasSelfRefTag = 0;
366
- Blob bHname = BLOB_INITIALIZER;
367367
static Bag seen;
368368
const char *zErr = 0;
369369
370370
if( rid==0 ){
371371
isRepeat = 1;
@@ -374,11 +374,11 @@
374374
}else{
375375
isRepeat = 0;
376376
bag_insert(&seen, rid);
377377
}
378378
379
- /* Every control artifact ends with a '\n' character. Exit early
379
+ /* Every structural artifact ends with a '\n' character. Exit early
380380
** if that is not the case for this artifact.
381381
*/
382382
if( !isRepeat ) g.parseCnt[0]++;
383383
z = blob_materialize(pContent);
384384
n = blob_size(pContent);
@@ -406,15 +406,10 @@
406406
blob_reset(pContent);
407407
blob_appendf(pErr, "incorrect Z-card cksum");
408408
return 0;
409409
}
410410
411
- /* Store the artifact hash (before modifying the blob) only for error
412
- ** reporting purposes.
413
- */
414
- sha1sum_blob(pContent, &bHname);
415
-
416411
/* Allocate a Manifest object to hold the parsed control artifact.
417412
*/
418413
p = fossil_malloc( sizeof(*p) );
419414
memset(p, 0, sizeof(*p));
420415
memcpy(&p->content, pContent, sizeof(p->content));
@@ -950,17 +945,19 @@
950945
if( !seenZ ) SYNTAX("missing Z-card on control");
951946
p->type = CFTYPE_CONTROL;
952947
}
953948
md5sum_init();
954949
if( !isRepeat ) g.parseCnt[p->type]++;
955
- blob_reset(&bHname);
956950
return p;
957951
958952
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
+ }
962959
}
963960
if( zErr ){
964961
blob_appendf(pErr, "line %d: %s", lineNo, zErr);
965962
}else{
966963
blob_appendf(pErr, "unknown error on line %d", lineNo);
967964
--- 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

Keyboard Shortcuts

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