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.
Commit
e73c8c44204ad807fc99360344bfdd44845b67850a6de5156b0e23e639753a9e
Parent
70cae41d43c15de…
1 file changed
+3
-8
+3
-8
| --- src/configure.c | ||
| +++ src/configure.c | ||
| @@ -299,11 +299,11 @@ | ||
| 299 | 299 | } |
| 300 | 300 | rebuildMask = 0; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /* |
| 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: | |
| 305 | 305 | ** |
| 306 | 306 | ** * A string literal |
| 307 | 307 | ** * A blob literal |
| 308 | 308 | ** * An integer literal (no floating point) |
| 309 | 309 | ** * NULL |
| @@ -319,17 +319,13 @@ | ||
| 319 | 319 | if( z[i]=='\'' ){ continue; } |
| 320 | 320 | return z[i]==0; |
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 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 | 324 | } |
| 330 | - return 1; | |
| 325 | + for(i=0; fossil_isdigit(z[i]); i++){} | |
| 326 | + return z[i]==0 || fossil_stricmp(z,"NULL")==0; | |
| 331 | 327 | } |
| 332 | 328 | |
| 333 | 329 | /* |
| 334 | 330 | ** Return true if z[] consists of nothing but digits |
| 335 | 331 | */ |
| @@ -411,11 +407,10 @@ | ||
| 411 | 407 | } |
| 412 | 408 | if( ii>=count(aType) ) return; |
| 413 | 409 | |
| 414 | 410 | while( blob_token(pContent, &name) && blob_sqltoken(pContent, &value) ){ |
| 415 | 411 | char *z = blob_terminate(&name); |
| 416 | - if( !safeSql(z) ) return; | |
| 417 | 412 | if( nToken>0 ){ |
| 418 | 413 | for(jj=0; jj<aType[ii].nField; jj++){ |
| 419 | 414 | if( fossil_strcmp(aType[ii].azField[jj], z)==0 ) break; |
| 420 | 415 | } |
| 421 | 416 | if( jj>=aType[ii].nField ) continue; |
| 422 | 417 |
| --- 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 |