summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRemi NGUYEN VAN <remi.nguyenvan+openwrt@gmail.com>2020-08-15 13:50:27 +0900
committerJo-Philipp Wich <jo@mein.io>2020-08-20 15:38:36 +0200
commit78d52a28c66ad0fd2af250038fdcf4239ad37bf2 (patch)
tree5c98b1a117cae797a74c7c3faf9e40af3b989fff
parente9b90dfac2225927c035f6a76277b850c282dc9a (diff)
downloadfirewall3-78d52a28c66ad0fd2af250038fdcf4239ad37bf2.tar.gz
options: fix parsing of boolean attributes
Boolean attributes were parsed the same way as string attributes, so a value of { "bool_attr": "true" } would be parsed correctly, but { "bool_attr": true } (without quotes) was parsed as false. Fixes FS#3284 Signed-off-by: Remi NGUYEN VAN <remi.nguyenvan+openwrt@gmail.com>
-rw-r--r--options.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/options.c b/options.c
index aed0cfb..6131786 100644
--- a/options.c
+++ b/options.c
@@ -1170,6 +1170,9 @@ fw3_parse_blob_options(void *s, const struct fw3_option *opts,
if (blobmsg_type(e) == BLOBMSG_TYPE_INT32) {
snprintf(buf, sizeof(buf), "%d", blobmsg_get_u32(e));
v = buf;
+ } else if (blobmsg_type(o) == BLOBMSG_TYPE_BOOL) {
+ snprintf(buf, sizeof(buf), "%d", blobmsg_get_bool(o));
+ v = buf;
} else {
v = blobmsg_get_string(e);
}
@@ -1189,6 +1192,9 @@ fw3_parse_blob_options(void *s, const struct fw3_option *opts,
if (blobmsg_type(o) == BLOBMSG_TYPE_INT32) {
snprintf(buf, sizeof(buf), "%d", blobmsg_get_u32(o));
v = buf;
+ } else if (blobmsg_type(o) == BLOBMSG_TYPE_BOOL) {
+ snprintf(buf, sizeof(buf), "%d", blobmsg_get_bool(o));
+ v = buf;
} else {
v = blobmsg_get_string(o);
}