From: Fredrik Thulin Date: Sun, 26 Dec 2010 21:21:58 +0000 (+0100) Subject: ykp_write_config: Only output flags if all bits match. X-Git-Tag: v1.4.0~23^2~1 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc1775c837b28fe23df1f09be0d7ea7152351923;p=yubikey-personalization.old ykp_write_config: Only output flags if all bits match. Do not output a false positive for a config/ticket flag if only some bits match. Without this patch, a configuration with the single cfgflag STRONG_PW2 was shown as STRONG_PW2|OATH_FIXED_MODHEX2|OATH_FIXED_MODHEX since there are some bits matching STRONG_PW2 (0x40) in OATH_FIXED_MODHEX (0x50). With this patch, single cfgflag STRONG_PW2 is shown as STRONG_PW2|OATH_FIXED_MODHEX2 OATH_FIXED_MODHEX2 is also shown as it shares the value of 0x40, and the outputting is not context aware (yet). --- diff --git a/ykpers.c b/ykpers.c index 5dbc693..ae3922f 100644 --- a/ykpers.c +++ b/ykpers.c @@ -427,7 +427,7 @@ int ykp_write_config(const YKP_CONFIG *cfg, buffer[0] = '\0'; for (p = ticket_flags_map; p->flag; p++) { - if (cfg->ykcore_config.tktFlags & p->flag + if ((cfg->ykcore_config.tktFlags & p->flag) == p->flag && p->vcheck(cfg)) { if (*buffer) { strcat(buffer, str_flags_separator); @@ -446,7 +446,7 @@ int ykp_write_config(const YKP_CONFIG *cfg, buffer[0] = '\0'; for (p = config_flags_map; p->flag; p++) { - if (cfg->ykcore_config.cfgFlags & p->flag + if ((cfg->ykcore_config.cfgFlags & p->flag) == p->flag && p->vcheck(cfg)) { if (*buffer) { strcat(buffer, str_flags_separator);