Fossil SCM

In safeSql(), take a blob literal only if it holds an even number of hex digits. Other X' tokens passed and ended the insert with a database error.

dmestas 2026-11-18 19:25 UTC small-fixes
Commit ab67c854c850583c38990aa2e23cc720377c286ab3ae3eb86ebd20a4e9473bc7
1 file changed +4 -1
+4 -1
--- src/configure.c
+++ src/configure.c
@@ -309,11 +309,14 @@
309309
** * NULL
310310
*/
311311
static int safeSql(const char *z){
312312
int i;
313313
if( z==0 || z[0]==0 ) return 0;
314
- if( (z[0]=='x' || z[0]=='X') && z[1]=='\'' ) z++;
314
+ if( (z[0]=='x' || z[0]=='X') && z[1]=='\'' ){
315
+ int n = (int)strlen(z);
316
+ return z[n-1]=='\'' && (n-3)%2==0 && validate16(&z[2], n-3);
317
+ }
315318
if( z[0]=='\'' ){
316319
for(i=1; z[i]; i++){
317320
if( z[i]=='\'' ){
318321
i++;
319322
if( z[i]=='\'' ){ continue; }
320323
--- src/configure.c
+++ src/configure.c
@@ -309,11 +309,14 @@
309 ** * NULL
310 */
311 static int safeSql(const char *z){
312 int i;
313 if( z==0 || z[0]==0 ) return 0;
314 if( (z[0]=='x' || z[0]=='X') && z[1]=='\'' ) z++;
 
 
 
315 if( z[0]=='\'' ){
316 for(i=1; z[i]; i++){
317 if( z[i]=='\'' ){
318 i++;
319 if( z[i]=='\'' ){ continue; }
320
--- src/configure.c
+++ src/configure.c
@@ -309,11 +309,14 @@
309 ** * NULL
310 */
311 static int safeSql(const char *z){
312 int i;
313 if( z==0 || z[0]==0 ) return 0;
314 if( (z[0]=='x' || z[0]=='X') && z[1]=='\'' ){
315 int n = (int)strlen(z);
316 return z[n-1]=='\'' && (n-3)%2==0 && validate16(&z[2], n-3);
317 }
318 if( z[0]=='\'' ){
319 for(i=1; z[i]; i++){
320 if( z[i]=='\'' ){
321 i++;
322 if( z[i]=='\'' ){ continue; }
323

Keyboard Shortcuts

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