From: Klas Lindfors Date: Thu, 25 Apr 2013 08:44:19 +0000 (+0200) Subject: add parsing of targetConfig to import X-Git-Tag: v1.14.0~21 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04096a9a0c84e5250b8b5e4549cb29a00ab1901a;p=yubikey-personalization add parsing of targetConfig to import --- diff --git a/ykpers-json.c b/ykpers-json.c index 285f1a7..1c19e3e 100644 --- a/ykpers-json.c +++ b/ykpers-json.c @@ -185,6 +185,7 @@ int _ykp_json_import_cfg(YKP_CONFIG *cfg, const char *json, size_t len) { json_object *yprod_json = json_object_object_get(jobj, "yubiProdConfig"); json_object *jmode = json_object_object_get(yprod_json, "mode"); json_object *options = json_object_object_get(yprod_json, "options"); + json_object *jtarget; const char *raw_mode; int mode = MODE_OTP_YUBICO; struct map_st *p; @@ -199,6 +200,20 @@ int _ykp_json_import_cfg(YKP_CONFIG *cfg, const char *json, size_t len) { return 0; } + jtarget = json_object_object_get(yprod_json, "targetConfig"); + if(jtarget) { + int target_config = json_object_get_int(jtarget); + if(target_config == 1 && + cfg->command != SLOT_CONFIG) { + ykp_errno = YKP_EINVAL; + return 0; + } else if(target_config == 2 && + cfg->command != SLOT_CONFIG2) { + ykp_errno = YKP_EINVAL; + return 0; + } + } + raw_mode = json_object_get_string(jmode); for(p = _modes_map; p->flag; p++) {