Fossil SCM
In symbolic_name_to_rid(), resolve rid:N only when N is the record number of an entry in the blob table, so that a number that names nothing or is too large is unresolved rather than passed through or wrapped. A bare "rid:" with a type is no longer an SQL error.
Commit
0495461514060232008f79ecac5272b444939210f39fcaf21b9d4bf3b373ac9c
Parent
aca3f562505247a…
1 file changed
+3
-2
+3
-2
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -701,13 +701,14 @@ | ||
| 701 | 701 | |
| 702 | 702 | /* Undocumented: numeric tags get translated directly into the RID */ |
| 703 | 703 | if( strncmp(zTag, "rid:", 4)==0 ){ |
| 704 | 704 | zTag += 4; |
| 705 | 705 | for(i=0; fossil_isdigit(zTag[i]); i++){} |
| 706 | - if( zTag[i]==0 ){ | |
| 706 | + if( i>0 && zTag[i]==0 ){ | |
| 707 | 707 | if( strcmp(zType,"*")==0 ){ |
| 708 | - rid = atoi(zTag); | |
| 708 | + rid = db_int(0, "SELECT rid FROM blob WHERE rid=%s", | |
| 709 | + zTag /*safe-for-%s*/); | |
| 709 | 710 | }else{ |
| 710 | 711 | rid = db_int(0, |
| 711 | 712 | "SELECT event.objid" |
| 712 | 713 | " FROM event" |
| 713 | 714 | " WHERE event.objid=%s" |
| 714 | 715 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -701,13 +701,14 @@ | |
| 701 | |
| 702 | /* Undocumented: numeric tags get translated directly into the RID */ |
| 703 | if( strncmp(zTag, "rid:", 4)==0 ){ |
| 704 | zTag += 4; |
| 705 | for(i=0; fossil_isdigit(zTag[i]); i++){} |
| 706 | if( zTag[i]==0 ){ |
| 707 | if( strcmp(zType,"*")==0 ){ |
| 708 | rid = atoi(zTag); |
| 709 | }else{ |
| 710 | rid = db_int(0, |
| 711 | "SELECT event.objid" |
| 712 | " FROM event" |
| 713 | " WHERE event.objid=%s" |
| 714 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -701,13 +701,14 @@ | |
| 701 | |
| 702 | /* Undocumented: numeric tags get translated directly into the RID */ |
| 703 | if( strncmp(zTag, "rid:", 4)==0 ){ |
| 704 | zTag += 4; |
| 705 | for(i=0; fossil_isdigit(zTag[i]); i++){} |
| 706 | if( i>0 && zTag[i]==0 ){ |
| 707 | if( strcmp(zType,"*")==0 ){ |
| 708 | rid = db_int(0, "SELECT rid FROM blob WHERE rid=%s", |
| 709 | zTag /*safe-for-%s*/); |
| 710 | }else{ |
| 711 | rid = db_int(0, |
| 712 | "SELECT event.objid" |
| 713 | " FROM event" |
| 714 | " WHERE event.objid=%s" |
| 715 |