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).

stephan 2014-09-11 17:25 trunk
Commit 57f0bb98c6cc0e02d9f6c99cc5afb76a3c3084e2
2 files changed +8 -8 +1 -1
+8 -8
--- src/json.c
+++ src/json.c
@@ -18,11 +18,11 @@
1818
**
1919
** Code for the JSON API.
2020
**
2121
** For notes regarding the public JSON interface, please see:
2222
**
23
-** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/edit
23
+** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/view
2424
**
2525
**
2626
** Notes for hackers...
2727
**
2828
** Here's how command/page dispatching works: json_page_top() (in HTTP mode) or
@@ -57,11 +57,11 @@
5757
5858
5959
/*
6060
** Returns true (non-0) if fossil appears to be running in JSON mode.
6161
*/
62
-char fossil_has_json(){
62
+int fossil_has_json(){
6363
return g.json.isJsonMode && (g.isHTTP || g.json.post.o);
6464
}
6565
6666
/*
6767
** Placeholder /json/XXX page impl for NYI (Not Yet Implemented)
@@ -384,11 +384,11 @@
384384
** either 0 or 1, as opposed to "0 or non-zero", so that clients can
385385
** pass a different value as dflt. Thus they can use, e.g. -1 to know
386386
** whether or not this function found a match (it will return -1 in
387387
** that case).
388388
*/
389
-char json_getenv_bool(char const * pKey, char dflt ){
389
+int json_getenv_bool(char const * pKey, int dflt ){
390390
cson_value const * v = json_getenv(pKey);
391391
const cson_type_id type = v ? cson_value_type_id(v) : CSON_TYPE_UNDEF;
392392
switch(type){
393393
case CSON_TYPE_INTEGER:
394394
case CSON_TYPE_DOUBLE:
@@ -475,15 +475,15 @@
475475
476476
/*
477477
** The boolean equivalent of json_find_option_cstr().
478478
** If the option is not found, dftl is returned.
479479
*/
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;
485485
if(!g.isHTTP){
486486
if(NULL != find_option(zCLILong ? zCLILong : zKey,
487487
zCLIShort, 0)){
488488
rc = 1;
489489
}
490490
--- 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
--- src/json_detail.h
+++ src/json_detail.h
@@ -257,11 +257,11 @@
257257
**
258258
** Whether or not we need to take args from CLI or POST data makes a
259259
** difference in argument/parameter handling in many JSON routines,
260260
** and thus this distinction.
261261
*/
262
-char fossil_has_json();
262
+int fossil_has_json();
263263
264264
enum json_get_changed_files_flags {
265265
json_get_changed_files_ELIDE_PARENT = 1 << 0
266266
};
267267
268268
--- 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

Keyboard Shortcuts

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