Fossil SCM

Fix recognition of sha3 in marks file. Patch adapted from Dingyuan Wang's report. Thanks!

jan.nijtmans 2018-01-16 08:34 trunk
Commit 90b07ed5880a844444f23f480ea185ef11ab38831470f1b80309b34d20de8566
1 file changed +5 -5
+5 -5
--- src/export.c
+++ src/export.c
@@ -35,16 +35,16 @@
3535
** and fossil commits.
3636
** -git_name: This is the mark name that identifies the commit to git.
3737
** It will always begin with a ':'.
3838
** -rid: The unique object ID that identifies this commit within the
3939
** repository database.
40
-** -uuid: The SHA-1 of artifact corresponding to rid.
40
+** -uuid: The SHA-1/SHA3 of artifact corresponding to rid.
4141
*/
4242
struct mark_t{
4343
char *name;
4444
int rid;
45
- char uuid[41];
45
+ char uuid[65];
4646
};
4747
#endif
4848
4949
/*
5050
** Output a "committer" record for the given user.
@@ -340,22 +340,22 @@
340340
}else{
341341
mark->name = fossil_strdup(cur_tok);
342342
}
343343
344344
cur_tok = strtok(NULL, "\n");
345
- if( !cur_tok || strlen(cur_tok)!=40 ){
345
+ if( !cur_tok || (strlen(cur_tok)!=40 && strlen(cur_tok)!=64) ){
346346
free(mark->name);
347
- fossil_trace("Invalid SHA-1 in marks file: %s\n", cur_tok);
347
+ fossil_trace("Invalid SHA-1/SHA-3 in marks file: %s\n", cur_tok);
348348
return -1;
349349
}else{
350350
sqlite3_snprintf(sizeof(mark->uuid), mark->uuid, "%s", cur_tok);
351351
}
352352
353353
/* make sure that rid corresponds to UUID */
354354
if( fast_uuid_to_rid(mark->uuid)!=mark->rid ){
355355
free(mark->name);
356
- fossil_trace("Non-existent SHA-1 in marks file: %s\n", mark->uuid);
356
+ fossil_trace("Non-existent SHA-1/SHA3 in marks file: %s\n", mark->uuid);
357357
return -1;
358358
}
359359
360360
/* insert a cross-ref into the 'xmark' table */
361361
insert_commit_xref(mark->rid, mark->name, mark->uuid);
362362
--- src/export.c
+++ src/export.c
@@ -35,16 +35,16 @@
35 ** and fossil commits.
36 ** -git_name: This is the mark name that identifies the commit to git.
37 ** It will always begin with a ':'.
38 ** -rid: The unique object ID that identifies this commit within the
39 ** repository database.
40 ** -uuid: The SHA-1 of artifact corresponding to rid.
41 */
42 struct mark_t{
43 char *name;
44 int rid;
45 char uuid[41];
46 };
47 #endif
48
49 /*
50 ** Output a "committer" record for the given user.
@@ -340,22 +340,22 @@
340 }else{
341 mark->name = fossil_strdup(cur_tok);
342 }
343
344 cur_tok = strtok(NULL, "\n");
345 if( !cur_tok || strlen(cur_tok)!=40 ){
346 free(mark->name);
347 fossil_trace("Invalid SHA-1 in marks file: %s\n", cur_tok);
348 return -1;
349 }else{
350 sqlite3_snprintf(sizeof(mark->uuid), mark->uuid, "%s", cur_tok);
351 }
352
353 /* make sure that rid corresponds to UUID */
354 if( fast_uuid_to_rid(mark->uuid)!=mark->rid ){
355 free(mark->name);
356 fossil_trace("Non-existent SHA-1 in marks file: %s\n", mark->uuid);
357 return -1;
358 }
359
360 /* insert a cross-ref into the 'xmark' table */
361 insert_commit_xref(mark->rid, mark->name, mark->uuid);
362
--- src/export.c
+++ src/export.c
@@ -35,16 +35,16 @@
35 ** and fossil commits.
36 ** -git_name: This is the mark name that identifies the commit to git.
37 ** It will always begin with a ':'.
38 ** -rid: The unique object ID that identifies this commit within the
39 ** repository database.
40 ** -uuid: The SHA-1/SHA3 of artifact corresponding to rid.
41 */
42 struct mark_t{
43 char *name;
44 int rid;
45 char uuid[65];
46 };
47 #endif
48
49 /*
50 ** Output a "committer" record for the given user.
@@ -340,22 +340,22 @@
340 }else{
341 mark->name = fossil_strdup(cur_tok);
342 }
343
344 cur_tok = strtok(NULL, "\n");
345 if( !cur_tok || (strlen(cur_tok)!=40 && strlen(cur_tok)!=64) ){
346 free(mark->name);
347 fossil_trace("Invalid SHA-1/SHA-3 in marks file: %s\n", cur_tok);
348 return -1;
349 }else{
350 sqlite3_snprintf(sizeof(mark->uuid), mark->uuid, "%s", cur_tok);
351 }
352
353 /* make sure that rid corresponds to UUID */
354 if( fast_uuid_to_rid(mark->uuid)!=mark->rid ){
355 free(mark->name);
356 fossil_trace("Non-existent SHA-1/SHA3 in marks file: %s\n", mark->uuid);
357 return -1;
358 }
359
360 /* insert a cross-ref into the 'xmark' table */
361 insert_commit_xref(mark->rid, mark->name, mark->uuid);
362

Keyboard Shortcuts

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