Fossil SCM
char-vs-int fixes in the JSON API: caused underflow (and thus incorrect is-flag-set results) on platforms where char is unsigned (Linux/ARM).
Commit
57f0bb98c6cc0e02d9f6c99cc5afb76a3c3084e2
Parent
c91bafccb5ee558…
2 files changed
+8
-8
+1
-1
+8
-8
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -18,11 +18,11 @@ | ||
| 18 | 18 | ** |
| 19 | 19 | ** Code for the JSON API. |
| 20 | 20 | ** |
| 21 | 21 | ** For notes regarding the public JSON interface, please see: |
| 22 | 22 | ** |
| 23 | -** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/edit | |
| 23 | +** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/view | |
| 24 | 24 | ** |
| 25 | 25 | ** |
| 26 | 26 | ** Notes for hackers... |
| 27 | 27 | ** |
| 28 | 28 | ** Here's how command/page dispatching works: json_page_top() (in HTTP mode) or |
| @@ -57,11 +57,11 @@ | ||
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | /* |
| 60 | 60 | ** Returns true (non-0) if fossil appears to be running in JSON mode. |
| 61 | 61 | */ |
| 62 | -char fossil_has_json(){ | |
| 62 | +int fossil_has_json(){ | |
| 63 | 63 | return g.json.isJsonMode && (g.isHTTP || g.json.post.o); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /* |
| 67 | 67 | ** Placeholder /json/XXX page impl for NYI (Not Yet Implemented) |
| @@ -384,11 +384,11 @@ | ||
| 384 | 384 | ** either 0 or 1, as opposed to "0 or non-zero", so that clients can |
| 385 | 385 | ** pass a different value as dflt. Thus they can use, e.g. -1 to know |
| 386 | 386 | ** whether or not this function found a match (it will return -1 in |
| 387 | 387 | ** that case). |
| 388 | 388 | */ |
| 389 | -char json_getenv_bool(char const * pKey, char dflt ){ | |
| 389 | +int json_getenv_bool(char const * pKey, int dflt ){ | |
| 390 | 390 | cson_value const * v = json_getenv(pKey); |
| 391 | 391 | const cson_type_id type = v ? cson_value_type_id(v) : CSON_TYPE_UNDEF; |
| 392 | 392 | switch(type){ |
| 393 | 393 | case CSON_TYPE_INTEGER: |
| 394 | 394 | case CSON_TYPE_DOUBLE: |
| @@ -475,15 +475,15 @@ | ||
| 475 | 475 | |
| 476 | 476 | /* |
| 477 | 477 | ** The boolean equivalent of json_find_option_cstr(). |
| 478 | 478 | ** If the option is not found, dftl is returned. |
| 479 | 479 | */ |
| 480 | -char json_find_option_bool(char const * zKey, | |
| 481 | - char const * zCLILong, | |
| 482 | - char const * zCLIShort, | |
| 483 | - char dflt ){ | |
| 484 | - char rc = -1; | |
| 480 | +int json_find_option_bool(char const * zKey, | |
| 481 | + char const * zCLILong, | |
| 482 | + char const * zCLIShort, | |
| 483 | + char dflt ){ | |
| 484 | + int rc = -1; | |
| 485 | 485 | if(!g.isHTTP){ |
| 486 | 486 | if(NULL != find_option(zCLILong ? zCLILong : zKey, |
| 487 | 487 | zCLIShort, 0)){ |
| 488 | 488 | rc = 1; |
| 489 | 489 | } |
| 490 | 490 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -18,11 +18,11 @@ | |
| 18 | ** |
| 19 | ** Code for the JSON API. |
| 20 | ** |
| 21 | ** For notes regarding the public JSON interface, please see: |
| 22 | ** |
| 23 | ** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/edit |
| 24 | ** |
| 25 | ** |
| 26 | ** Notes for hackers... |
| 27 | ** |
| 28 | ** Here's how command/page dispatching works: json_page_top() (in HTTP mode) or |
| @@ -57,11 +57,11 @@ | |
| 57 | |
| 58 | |
| 59 | /* |
| 60 | ** Returns true (non-0) if fossil appears to be running in JSON mode. |
| 61 | */ |
| 62 | char fossil_has_json(){ |
| 63 | return g.json.isJsonMode && (g.isHTTP || g.json.post.o); |
| 64 | } |
| 65 | |
| 66 | /* |
| 67 | ** Placeholder /json/XXX page impl for NYI (Not Yet Implemented) |
| @@ -384,11 +384,11 @@ | |
| 384 | ** either 0 or 1, as opposed to "0 or non-zero", so that clients can |
| 385 | ** pass a different value as dflt. Thus they can use, e.g. -1 to know |
| 386 | ** whether or not this function found a match (it will return -1 in |
| 387 | ** that case). |
| 388 | */ |
| 389 | char json_getenv_bool(char const * pKey, char dflt ){ |
| 390 | cson_value const * v = json_getenv(pKey); |
| 391 | const cson_type_id type = v ? cson_value_type_id(v) : CSON_TYPE_UNDEF; |
| 392 | switch(type){ |
| 393 | case CSON_TYPE_INTEGER: |
| 394 | case CSON_TYPE_DOUBLE: |
| @@ -475,15 +475,15 @@ | |
| 475 | |
| 476 | /* |
| 477 | ** The boolean equivalent of json_find_option_cstr(). |
| 478 | ** If the option is not found, dftl is returned. |
| 479 | */ |
| 480 | char json_find_option_bool(char const * zKey, |
| 481 | char const * zCLILong, |
| 482 | char const * zCLIShort, |
| 483 | char dflt ){ |
| 484 | char rc = -1; |
| 485 | if(!g.isHTTP){ |
| 486 | if(NULL != find_option(zCLILong ? zCLILong : zKey, |
| 487 | zCLIShort, 0)){ |
| 488 | rc = 1; |
| 489 | } |
| 490 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -18,11 +18,11 @@ | |
| 18 | ** |
| 19 | ** Code for the JSON API. |
| 20 | ** |
| 21 | ** For notes regarding the public JSON interface, please see: |
| 22 | ** |
| 23 | ** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/view |
| 24 | ** |
| 25 | ** |
| 26 | ** Notes for hackers... |
| 27 | ** |
| 28 | ** Here's how command/page dispatching works: json_page_top() (in HTTP mode) or |
| @@ -57,11 +57,11 @@ | |
| 57 | |
| 58 | |
| 59 | /* |
| 60 | ** Returns true (non-0) if fossil appears to be running in JSON mode. |
| 61 | */ |
| 62 | int fossil_has_json(){ |
| 63 | return g.json.isJsonMode && (g.isHTTP || g.json.post.o); |
| 64 | } |
| 65 | |
| 66 | /* |
| 67 | ** Placeholder /json/XXX page impl for NYI (Not Yet Implemented) |
| @@ -384,11 +384,11 @@ | |
| 384 | ** either 0 or 1, as opposed to "0 or non-zero", so that clients can |
| 385 | ** pass a different value as dflt. Thus they can use, e.g. -1 to know |
| 386 | ** whether or not this function found a match (it will return -1 in |
| 387 | ** that case). |
| 388 | */ |
| 389 | int json_getenv_bool(char const * pKey, int dflt ){ |
| 390 | cson_value const * v = json_getenv(pKey); |
| 391 | const cson_type_id type = v ? cson_value_type_id(v) : CSON_TYPE_UNDEF; |
| 392 | switch(type){ |
| 393 | case CSON_TYPE_INTEGER: |
| 394 | case CSON_TYPE_DOUBLE: |
| @@ -475,15 +475,15 @@ | |
| 475 | |
| 476 | /* |
| 477 | ** The boolean equivalent of json_find_option_cstr(). |
| 478 | ** If the option is not found, dftl is returned. |
| 479 | */ |
| 480 | int json_find_option_bool(char const * zKey, |
| 481 | char const * zCLILong, |
| 482 | char const * zCLIShort, |
| 483 | char dflt ){ |
| 484 | int rc = -1; |
| 485 | if(!g.isHTTP){ |
| 486 | if(NULL != find_option(zCLILong ? zCLILong : zKey, |
| 487 | zCLIShort, 0)){ |
| 488 | rc = 1; |
| 489 | } |
| 490 |
+1
-1
| --- src/json_detail.h | ||
| +++ src/json_detail.h | ||
| @@ -257,11 +257,11 @@ | ||
| 257 | 257 | ** |
| 258 | 258 | ** Whether or not we need to take args from CLI or POST data makes a |
| 259 | 259 | ** difference in argument/parameter handling in many JSON routines, |
| 260 | 260 | ** and thus this distinction. |
| 261 | 261 | */ |
| 262 | -char fossil_has_json(); | |
| 262 | +int fossil_has_json(); | |
| 263 | 263 | |
| 264 | 264 | enum json_get_changed_files_flags { |
| 265 | 265 | json_get_changed_files_ELIDE_PARENT = 1 << 0 |
| 266 | 266 | }; |
| 267 | 267 | |
| 268 | 268 |
| --- src/json_detail.h | |
| +++ src/json_detail.h | |
| @@ -257,11 +257,11 @@ | |
| 257 | ** |
| 258 | ** Whether or not we need to take args from CLI or POST data makes a |
| 259 | ** difference in argument/parameter handling in many JSON routines, |
| 260 | ** and thus this distinction. |
| 261 | */ |
| 262 | char fossil_has_json(); |
| 263 | |
| 264 | enum json_get_changed_files_flags { |
| 265 | json_get_changed_files_ELIDE_PARENT = 1 << 0 |
| 266 | }; |
| 267 | |
| 268 |
| --- src/json_detail.h | |
| +++ src/json_detail.h | |
| @@ -257,11 +257,11 @@ | |
| 257 | ** |
| 258 | ** Whether or not we need to take args from CLI or POST data makes a |
| 259 | ** difference in argument/parameter handling in many JSON routines, |
| 260 | ** and thus this distinction. |
| 261 | */ |
| 262 | int fossil_has_json(); |
| 263 | |
| 264 | enum json_get_changed_files_flags { |
| 265 | json_get_changed_files_ELIDE_PARENT = 1 << 0 |
| 266 | }; |
| 267 | |
| 268 |