summaryrefslogtreecommitdiffstats
path: root/src/modules/rlm_yubikey
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/rlm_yubikey')
-rw-r--r--src/modules/rlm_yubikey/decrypt.c2
-rw-r--r--src/modules/rlm_yubikey/rlm_yubikey.c19
2 files changed, 11 insertions, 10 deletions
diff --git a/src/modules/rlm_yubikey/decrypt.c b/src/modules/rlm_yubikey/decrypt.c
index 20b6df8..2bf4543 100644
--- a/src/modules/rlm_yubikey/decrypt.c
+++ b/src/modules/rlm_yubikey/decrypt.c
@@ -106,7 +106,7 @@ rlm_rcode_t rlm_yubikey_decrypt(rlm_yubikey_t *inst, REQUEST *request, char cons
* Combine the two counter fields together so we can do
* replay attack checks.
*/
- counter = (yubikey_counter(token.ctr) << 16) | token.use;
+ counter = (yubikey_counter(token.ctr) << 8) | token.use;
vp = fr_pair_make(request->packet, &request->packet->vps, "Yubikey-Counter", NULL, T_OP_SET);
if (!vp) {
diff --git a/src/modules/rlm_yubikey/rlm_yubikey.c b/src/modules/rlm_yubikey/rlm_yubikey.c
index 83b7655..5bbed11 100644
--- a/src/modules/rlm_yubikey/rlm_yubikey.c
+++ b/src/modules/rlm_yubikey/rlm_yubikey.c
@@ -77,19 +77,16 @@ static ssize_t modhex2hex(char const *modhex, uint8_t *hex, size_t len)
size_t i;
char *c1, *c2;
- for (i = 0; i < len; i++) {
- if (modhex[i << 1] == '\0') {
- break;
- }
+ for (i = 0; i < len; i += 2) {
+ if (modhex[i] == '\0') break;
/*
* We only deal with whole bytes
*/
- if (modhex[(i << 1) + 1] == '\0')
- return -1;
+ if (modhex[i + 1] == '\0') return -1;
- if (!(c1 = memchr(modhextab, tolower((uint8_t) modhex[i << 1]), 16)) ||
- !(c2 = memchr(modhextab, tolower((uint8_t) modhex[(i << 1) + 1]), 16)))
+ if (!(c1 = memchr(modhextab, tolower((uint8_t) modhex[i]), 16)) ||
+ !(c2 = memchr(modhextab, tolower((uint8_t) modhex[i + 1]), 16)))
return -1;
hex[i] = hextab[c1 - modhextab];
@@ -124,6 +121,10 @@ static ssize_t modhex_to_hex_xlat(UNUSED void *instance, REQUEST *request, char
return -1;
}
+ if (len < (ssize_t) outlen) {
+ out[len] = '\0';
+ }
+
return len;
}
@@ -142,7 +143,7 @@ static int mod_bootstrap(CONF_SECTION *conf, void *instance)
}
#endif
- if (!cf_section_name2(conf)) return 0;
+ if (cf_section_name2(conf)) return 0;
xlat_register("modhextohex", modhex_to_hex_xlat, NULL, inst);