Fossil SCM

In configure_receive(), take a value in a received config card only if it is a string or blob literal, an integer or NULL, as safeSql() says. Any word of letters and digits passed and was read as a column name, and the insert failed with a database error.

dmestas 2026-11-18 19:22 UTC small-fixes
Commit e73c8c44204ad807fc99360344bfdd44845b67850a6de5156b0e23e639753a9e
1 file changed +3 -8
+3 -8
--- src/configure.c
+++ src/configure.c
@@ -299,11 +299,11 @@
299299
}
300300
rebuildMask = 0;
301301
}
302302
303303
/*
304
-** Return true if z[] is not a "safe" SQL token. A safe token is one of:
304
+** Return true if z[] is a "safe" SQL token. A safe token is one of:
305305
**
306306
** * A string literal
307307
** * A blob literal
308308
** * An integer literal (no floating point)
309309
** * NULL
@@ -319,17 +319,13 @@
319319
if( z[i]=='\'' ){ continue; }
320320
return z[i]==0;
321321
}
322322
}
323323
return 0;
324
- }else{
325
- char c;
326
- for(i=0; (c = z[i])!=0; i++){
327
- if( !fossil_isalnum(c) ) return 0;
328
- }
329324
}
330
- return 1;
325
+ for(i=0; fossil_isdigit(z[i]); i++){}
326
+ return z[i]==0 || fossil_stricmp(z,"NULL")==0;
331327
}
332328
333329
/*
334330
** Return true if z[] consists of nothing but digits
335331
*/
@@ -411,11 +407,10 @@
411407
}
412408
if( ii>=count(aType) ) return;
413409
414410
while( blob_token(pContent, &name) && blob_sqltoken(pContent, &value) ){
415411
char *z = blob_terminate(&name);
416
- if( !safeSql(z) ) return;
417412
if( nToken>0 ){
418413
for(jj=0; jj<aType[ii].nField; jj++){
419414
if( fossil_strcmp(aType[ii].azField[jj], z)==0 ) break;
420415
}
421416
if( jj>=aType[ii].nField ) continue;
422417
--- src/configure.c
+++ src/configure.c
@@ -299,11 +299,11 @@
299 }
300 rebuildMask = 0;
301 }
302
303 /*
304 ** Return true if z[] is not a "safe" SQL token. A safe token is one of:
305 **
306 ** * A string literal
307 ** * A blob literal
308 ** * An integer literal (no floating point)
309 ** * NULL
@@ -319,17 +319,13 @@
319 if( z[i]=='\'' ){ continue; }
320 return z[i]==0;
321 }
322 }
323 return 0;
324 }else{
325 char c;
326 for(i=0; (c = z[i])!=0; i++){
327 if( !fossil_isalnum(c) ) return 0;
328 }
329 }
330 return 1;
 
331 }
332
333 /*
334 ** Return true if z[] consists of nothing but digits
335 */
@@ -411,11 +407,10 @@
411 }
412 if( ii>=count(aType) ) return;
413
414 while( blob_token(pContent, &name) && blob_sqltoken(pContent, &value) ){
415 char *z = blob_terminate(&name);
416 if( !safeSql(z) ) return;
417 if( nToken>0 ){
418 for(jj=0; jj<aType[ii].nField; jj++){
419 if( fossil_strcmp(aType[ii].azField[jj], z)==0 ) break;
420 }
421 if( jj>=aType[ii].nField ) continue;
422
--- src/configure.c
+++ src/configure.c
@@ -299,11 +299,11 @@
299 }
300 rebuildMask = 0;
301 }
302
303 /*
304 ** Return true if z[] is a "safe" SQL token. A safe token is one of:
305 **
306 ** * A string literal
307 ** * A blob literal
308 ** * An integer literal (no floating point)
309 ** * NULL
@@ -319,17 +319,13 @@
319 if( z[i]=='\'' ){ continue; }
320 return z[i]==0;
321 }
322 }
323 return 0;
 
 
 
 
 
324 }
325 for(i=0; fossil_isdigit(z[i]); i++){}
326 return z[i]==0 || fossil_stricmp(z,"NULL")==0;
327 }
328
329 /*
330 ** Return true if z[] consists of nothing but digits
331 */
@@ -411,11 +407,10 @@
407 }
408 if( ii>=count(aType) ) return;
409
410 while( blob_token(pContent, &name) && blob_sqltoken(pContent, &value) ){
411 char *z = blob_terminate(&name);
 
412 if( nToken>0 ){
413 for(jj=0; jj<aType[ii].nField; jj++){
414 if( fossil_strcmp(aType[ii].azField[jj], z)==0 ) break;
415 }
416 if( jj>=aType[ii].nField ) continue;
417

Keyboard Shortcuts

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