Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the /hash-collisions webpage. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
43e2aff58ae2bc0c59742038fd7eeefc |
| User & Date: | drh 2015-02-11 11:51:11.078 |
Context
|
2015-02-11
| ||
| 12:03 | On the /hash-collisions page show the true first instance of each collision, not the second. check-in: 4ce3a2bfac user: drh tags: trunk | |
| 11:51 | Add the /hash-collisions webpage. check-in: 43e2aff58a user: drh tags: trunk | |
| 11:09 | Use the "%S" formatting option for human-readable SHA1 hashes and "%!S" for SHA1 hashes in URLs. The length of these hashes are compile-time configurable using FOSSIL_SHA1_PREFIX_LEN and FOSSIL_SHA1_URLPREFIX_LEN, respectively. Defaults: 10 and 16. check-in: 1fee0377e4 user: drh tags: trunk | |
Changes
Changes to src/name.c.
| ︙ | ︙ | |||
1056 1057 1058 1059 1060 1061 1062 |
**
** Show all phantom artifacts
*/
void test_phatoms_cmd(void){
db_find_and_open_repository(0,0);
describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0);
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 |
**
** Show all phantom artifacts
*/
void test_phatoms_cmd(void){
db_find_and_open_repository(0,0);
describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0);
}
/*
** WEBPAGE: hash-collisions
**
** Show the number of hash collisions for hash prefixes of various lengths.
*/
void hash_collisions_webpage(void){
int i;
int nHash = 0;
Stmt q;
char zPrev[UUID_SIZE+1];
struct {
int cnt;
char z[UUID_SIZE+1];
} aCollide[UUID_SIZE+1];
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
memset(aCollide, 0, sizeof(aCollide));
memset(zPrev, 0, sizeof(zPrev));
db_prepare(&q,
"SELECT tkt_uuid FROM ticket\n"
"UNION ALL\n"
"SELECT substr(tagname,7) FROM tag WHERE tagname GLOB 'event-*'\n"
"UNION ALL\n"
"SELECT uuid FROM blob\n"
"ORDER BY 1"
);
while( db_step(&q)==SQLITE_ROW ){
const char *zUuid = db_column_text(&q,0);
int n = db_column_bytes(&q,0);
int i;
nHash++;
for(i=0; zPrev[i] && zPrev[i]==zUuid[i]; i++){}
memcpy(zPrev, zUuid, n+1);
if( i>0 && i<=UUID_SIZE ){
aCollide[i].cnt++;
if( aCollide[i].z[0]==0 ) memcpy(aCollide[i].z, zPrev, n+1);
}
}
db_finalize(&q);
style_header("Hash Prefix Collisions");
@ <table border=1><thead>
@ <tr><th>Length<th>Instances<th>First Instance</tr>
@ </thead><tbody>
for(i=1; i<UUID_SIZE; i++){
if( aCollide[i].cnt==0 ) continue;
@ <tr><td>%d(i)<td>%d(aCollide[i].cnt)<td>%h(aCollide[i].z)</tr>
}
@ </tbody></table>
@ <p>Total number of hashes: %d(nHash)</p>
style_footer();
}
|