aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--lib/libotputil/lrfc2289-otp.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/libotputil/lrfc2289-otp.c b/lib/libotputil/lrfc2289-otp.c
index 807c2da..1ba7828 100644
--- a/lib/libotputil/lrfc2289-otp.c
+++ b/lib/libotputil/lrfc2289-otp.c
@@ -85,20 +85,23 @@ otputil_otp_code(
85 int pos; 85 int pos;
86 86
87 assert(otp_pass != NULL); 87 assert(otp_pass != NULL);
88 assert(otp_seed != NULL);
89 88
90 // check otp_seed 89 // check otp_seed
91 for(len = 0; ((otp_seed[len])); len++) 90 secret[0] = '\0';
91 if ((otp_seed))
92 { 92 {
93 if (len > OTPUTIL_OTP_SEED_MAX_LEN) 93 for(len = 0; ((otp_seed[len])); len++)
94 return(-1); 94 {
95 if (!(isalnum(otp_seed[len]))) 95 if (len > OTPUTIL_OTP_SEED_MAX_LEN)
96 return(-1);
97 if (!(isalnum(otp_seed[len])))
98 return(-1);
99 secret[len] = tolower(otp_seed[len]);
100 };
101 secret[len] = '\0';
102 if (len < OTPUTIL_OTP_SEED_MIN_LEN)
96 return(-1); 103 return(-1);
97 secret[len] = tolower(otp_seed[len]);
98 }; 104 };
99 secret[len] = '\0';
100 if (len < OTPUTIL_OTP_SEED_MIN_LEN)
101 return(-1);
102 105
103 // check otp_pass 106 // check otp_pass
104 len = strlen(otp_pass); 107 len = strlen(otp_pass);