plist: fix inverted strcmp in string to boolean conversion plist_dict_get_bool() compared the string value with strcmp() but treated a non-zero return as a match. strcmp() returns 0 on equality, so the conditions were inverted: "true" produced 0, "false" produced 1, and any other string also produced 1. The error branch could never be reached, since it required both comparisons to return 0 at once. The result is that the API returns the opposite of the stored value for both valid boolean strings, and returns true for strings that are not booleans at all, instead of reporting the conversion error. Compare == 0 in both conditions: input before after true 0 1 false 1 0 not-a-bool 1 error TRUE 1 error (empty) 1 error Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
diff --git a/src/plist.c b/src/plist.c index 5ea6c12..bcd212c 100644 --- a/src/plist.c +++ b/src/plist.c
@@ -1495,9 +1495,9 @@ case PLIST_STRING: strval = plist_get_string_ptr(node, NULL); if (strval) { - if (strcmp(strval, "true")) { + if (strcmp(strval, "true") == 0) { bval = 1; - } else if (strcmp(strval, "false")) { + } else if (strcmp(strval, "false") == 0) { bval = 0; } else { PLIST_ERR("%s: invalid string '%s' for string to boolean conversion\n", __func__, strval);