From bd68e726e45c10fd223814eaf6129e1bb2f7b022 Mon Sep 17 00:00:00 2001 From: Arpit Jain Date: Wed, 29 Jul 2026 14:25:18 +0900 Subject: 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 --- src/plist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 @@ uint8_t plist_dict_get_bool(plist_t dict, const char *key) 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); -- cgit v1.1-32-gdbae