Fossil SCM
Fix some cases in wikiformat.c where it was assuming that a hash name would be UUID_SIZE or fewer characters, when in fact the size could be as many as HNAME_MAX characters. This is a change that we missed in the SHA3 cut-over.
Commit
e0757d270c3c10d46a8aabe1865ec384d878af089d0c917764838452ed2f7b56
Parent
a10fc448ed3fce5…
1 file changed
+6
-6
+6
-6
| --- src/wikiformat.c | ||
| +++ src/wikiformat.c | ||
| @@ -1065,26 +1065,26 @@ | ||
| 1065 | 1065 | |
| 1066 | 1066 | /* |
| 1067 | 1067 | ** If the input string corresponds to an existing baseline, |
| 1068 | 1068 | ** return true. |
| 1069 | 1069 | */ |
| 1070 | -static int is_valid_uuid(const char *z){ | |
| 1070 | +static int is_valid_hname(const char *z){ | |
| 1071 | 1071 | int n = strlen(z); |
| 1072 | 1072 | if( n<4 || n>HNAME_MAX ) return 0; |
| 1073 | 1073 | if( !validate16(z, n) ) return 0; |
| 1074 | 1074 | return 1; |
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | /* |
| 1078 | -** Return TRUE if a UUID corresponds to an artifact in this | |
| 1078 | +** Return TRUE if a hash name corresponds to an artifact in this | |
| 1079 | 1079 | ** repository. |
| 1080 | 1080 | */ |
| 1081 | 1081 | static int in_this_repo(const char *zUuid){ |
| 1082 | 1082 | static Stmt q; |
| 1083 | 1083 | int rc; |
| 1084 | 1084 | int n; |
| 1085 | - char zU2[UUID_SIZE+1]; | |
| 1085 | + char zU2[HNAME_MAX+1]; | |
| 1086 | 1086 | db_static_prepare(&q, |
| 1087 | 1087 | "SELECT 1 FROM blob WHERE uuid>=:u AND uuid<:u2" |
| 1088 | 1088 | ); |
| 1089 | 1089 | db_bind_text(&q, ":u", zUuid); |
| 1090 | 1090 | n = (int)strlen(zUuid); |
| @@ -1216,13 +1216,13 @@ | ||
| 1216 | 1216 | && (zTarget[1]=='/' || (zTarget[1]=='.' && zTarget[2]=='/')) |
| 1217 | 1217 | && (p->state & WIKI_LINKSONLY)==0 ){ |
| 1218 | 1218 | blob_appendf(p->pOut, "<a href=\"%h\">", zTarget); |
| 1219 | 1219 | }else if( zTarget[0]=='#' ){ |
| 1220 | 1220 | blob_appendf(p->pOut, "<a href=\"%h\">", zTarget); |
| 1221 | - }else if( is_valid_uuid(zTarget) ){ | |
| 1221 | + }else if( is_valid_hname(zTarget) ){ | |
| 1222 | 1222 | int isClosed = 0; |
| 1223 | - if( is_ticket(zTarget, &isClosed) ){ | |
| 1223 | + if( strlen(zTarget)<=UUID_SIZE && is_ticket(zTarget, &isClosed) ){ | |
| 1224 | 1224 | /* Special display processing for tickets. Display the hyperlink |
| 1225 | 1225 | ** as crossed out if the ticket is closed. |
| 1226 | 1226 | */ |
| 1227 | 1227 | if( isClosed ){ |
| 1228 | 1228 | if( g.perm.Hyperlink ){ |
| @@ -1839,11 +1839,11 @@ | ||
| 1839 | 1839 | zTarget = &z[1]; |
| 1840 | 1840 | for(i=0; zTarget[i] && zTarget[i]!='|' && zTarget[i]!=']'; i++){} |
| 1841 | 1841 | while(i>1 && zTarget[i-1]==' '){ i--; } |
| 1842 | 1842 | c = zTarget[i]; |
| 1843 | 1843 | zTarget[i] = 0; |
| 1844 | - if( is_valid_uuid(zTarget) ){ | |
| 1844 | + if( is_valid_hname(zTarget) ){ | |
| 1845 | 1845 | memcpy(zLink, zTarget, i+1); |
| 1846 | 1846 | canonical16(zLink, i); |
| 1847 | 1847 | db_multi_exec( |
| 1848 | 1848 | "REPLACE INTO backlink(target,srctype,srcid,mtime)" |
| 1849 | 1849 | "VALUES(%Q,%d,%d,%g)", zLink, srctype, srcid, mtime |
| 1850 | 1850 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -1065,26 +1065,26 @@ | |
| 1065 | |
| 1066 | /* |
| 1067 | ** If the input string corresponds to an existing baseline, |
| 1068 | ** return true. |
| 1069 | */ |
| 1070 | static int is_valid_uuid(const char *z){ |
| 1071 | int n = strlen(z); |
| 1072 | if( n<4 || n>HNAME_MAX ) return 0; |
| 1073 | if( !validate16(z, n) ) return 0; |
| 1074 | return 1; |
| 1075 | } |
| 1076 | |
| 1077 | /* |
| 1078 | ** Return TRUE if a UUID corresponds to an artifact in this |
| 1079 | ** repository. |
| 1080 | */ |
| 1081 | static int in_this_repo(const char *zUuid){ |
| 1082 | static Stmt q; |
| 1083 | int rc; |
| 1084 | int n; |
| 1085 | char zU2[UUID_SIZE+1]; |
| 1086 | db_static_prepare(&q, |
| 1087 | "SELECT 1 FROM blob WHERE uuid>=:u AND uuid<:u2" |
| 1088 | ); |
| 1089 | db_bind_text(&q, ":u", zUuid); |
| 1090 | n = (int)strlen(zUuid); |
| @@ -1216,13 +1216,13 @@ | |
| 1216 | && (zTarget[1]=='/' || (zTarget[1]=='.' && zTarget[2]=='/')) |
| 1217 | && (p->state & WIKI_LINKSONLY)==0 ){ |
| 1218 | blob_appendf(p->pOut, "<a href=\"%h\">", zTarget); |
| 1219 | }else if( zTarget[0]=='#' ){ |
| 1220 | blob_appendf(p->pOut, "<a href=\"%h\">", zTarget); |
| 1221 | }else if( is_valid_uuid(zTarget) ){ |
| 1222 | int isClosed = 0; |
| 1223 | if( is_ticket(zTarget, &isClosed) ){ |
| 1224 | /* Special display processing for tickets. Display the hyperlink |
| 1225 | ** as crossed out if the ticket is closed. |
| 1226 | */ |
| 1227 | if( isClosed ){ |
| 1228 | if( g.perm.Hyperlink ){ |
| @@ -1839,11 +1839,11 @@ | |
| 1839 | zTarget = &z[1]; |
| 1840 | for(i=0; zTarget[i] && zTarget[i]!='|' && zTarget[i]!=']'; i++){} |
| 1841 | while(i>1 && zTarget[i-1]==' '){ i--; } |
| 1842 | c = zTarget[i]; |
| 1843 | zTarget[i] = 0; |
| 1844 | if( is_valid_uuid(zTarget) ){ |
| 1845 | memcpy(zLink, zTarget, i+1); |
| 1846 | canonical16(zLink, i); |
| 1847 | db_multi_exec( |
| 1848 | "REPLACE INTO backlink(target,srctype,srcid,mtime)" |
| 1849 | "VALUES(%Q,%d,%d,%g)", zLink, srctype, srcid, mtime |
| 1850 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -1065,26 +1065,26 @@ | |
| 1065 | |
| 1066 | /* |
| 1067 | ** If the input string corresponds to an existing baseline, |
| 1068 | ** return true. |
| 1069 | */ |
| 1070 | static int is_valid_hname(const char *z){ |
| 1071 | int n = strlen(z); |
| 1072 | if( n<4 || n>HNAME_MAX ) return 0; |
| 1073 | if( !validate16(z, n) ) return 0; |
| 1074 | return 1; |
| 1075 | } |
| 1076 | |
| 1077 | /* |
| 1078 | ** Return TRUE if a hash name corresponds to an artifact in this |
| 1079 | ** repository. |
| 1080 | */ |
| 1081 | static int in_this_repo(const char *zUuid){ |
| 1082 | static Stmt q; |
| 1083 | int rc; |
| 1084 | int n; |
| 1085 | char zU2[HNAME_MAX+1]; |
| 1086 | db_static_prepare(&q, |
| 1087 | "SELECT 1 FROM blob WHERE uuid>=:u AND uuid<:u2" |
| 1088 | ); |
| 1089 | db_bind_text(&q, ":u", zUuid); |
| 1090 | n = (int)strlen(zUuid); |
| @@ -1216,13 +1216,13 @@ | |
| 1216 | && (zTarget[1]=='/' || (zTarget[1]=='.' && zTarget[2]=='/')) |
| 1217 | && (p->state & WIKI_LINKSONLY)==0 ){ |
| 1218 | blob_appendf(p->pOut, "<a href=\"%h\">", zTarget); |
| 1219 | }else if( zTarget[0]=='#' ){ |
| 1220 | blob_appendf(p->pOut, "<a href=\"%h\">", zTarget); |
| 1221 | }else if( is_valid_hname(zTarget) ){ |
| 1222 | int isClosed = 0; |
| 1223 | if( strlen(zTarget)<=UUID_SIZE && is_ticket(zTarget, &isClosed) ){ |
| 1224 | /* Special display processing for tickets. Display the hyperlink |
| 1225 | ** as crossed out if the ticket is closed. |
| 1226 | */ |
| 1227 | if( isClosed ){ |
| 1228 | if( g.perm.Hyperlink ){ |
| @@ -1839,11 +1839,11 @@ | |
| 1839 | zTarget = &z[1]; |
| 1840 | for(i=0; zTarget[i] && zTarget[i]!='|' && zTarget[i]!=']'; i++){} |
| 1841 | while(i>1 && zTarget[i-1]==' '){ i--; } |
| 1842 | c = zTarget[i]; |
| 1843 | zTarget[i] = 0; |
| 1844 | if( is_valid_hname(zTarget) ){ |
| 1845 | memcpy(zLink, zTarget, i+1); |
| 1846 | canonical16(zLink, i); |
| 1847 | db_multi_exec( |
| 1848 | "REPLACE INTO backlink(target,srctype,srcid,mtime)" |
| 1849 | "VALUES(%Q,%d,%d,%g)", zLink, srctype, srcid, mtime |
| 1850 |