Skip to content

Commit

Permalink
Get rid of FIELD_SIZE
Browse files Browse the repository at this point in the history
Rename the last occurrences of FIELD_SIZE to OTP_SIZE, as it is
only being used to define the size of otp.

Keep the original value of 64 for now.
  • Loading branch information
DimitriPapadopoulos committed Jan 21, 2021
1 parent 9ffb78c commit 644f8c9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ int load_config(struct vpn_config *cfg, const char *filename)
cfg->password[PASSWORD_SIZE] = '\0';
cfg->password_set = 1;
} else if (strcmp(key, "otp") == 0) {
strncpy(cfg->otp, val, FIELD_SIZE);
cfg->otp[FIELD_SIZE] = '\0';
strncpy(cfg->otp, val, OTP_SIZE);
cfg->otp[OTP_SIZE] = '\0';
} else if (strcmp(key, "otp-prompt") == 0) {
free(cfg->otp_prompt);
cfg->otp_prompt = strdup(val);
Expand Down
4 changes: 2 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ struct x509_digest {
char data[SHA256STRLEN];
};

#define FIELD_SIZE 64
#define GATEWAY_HOST_SIZE 253
#define USERNAME_SIZE 64
#define PASSWORD_SIZE 256
#define OTP_SIZE 64
#define REALM_SIZE 63

/*
Expand All @@ -88,7 +88,7 @@ struct vpn_config {
char username[USERNAME_SIZE + 1];
char password[PASSWORD_SIZE + 1];
int password_set;
char otp[FIELD_SIZE + 1];
char otp[OTP_SIZE + 1];
char *otp_prompt;
unsigned int otp_delay;
int no_ftm_push;
Expand Down
4 changes: 2 additions & 2 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ static int try_otp_auth(struct tunnel *tunnel, const char *buffer,
v = NULL;
if (cfg->otp[0] == '\0') {
read_password(cfg->pinentry, "otp",
p, cfg->otp, FIELD_SIZE);
p, cfg->otp, OTP_SIZE);
if (cfg->otp[0] == '\0') {
log_error("No OTP specified\n");
return 0;
Expand Down Expand Up @@ -730,7 +730,7 @@ int auth_log_in(struct tunnel *tunnel)
// Prompt for 2FA token
read_password(cfg->pinentry, "2fa",
"Two-factor authentication token: ",
cfg->otp, FIELD_SIZE);
cfg->otp, OTP_SIZE);

if (cfg->otp[0] == '\0') {
log_error("No token specified\n");
Expand Down
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,8 @@ int main(int argc, char **argv)
*optarg++ = '*'; // nuke it
break;
case 'o':
strncpy(cli_cfg.otp, optarg, FIELD_SIZE);
cli_cfg.otp[FIELD_SIZE] = '\0';
strncpy(cli_cfg.otp, optarg, OTP_SIZE);
cli_cfg.otp[OTP_SIZE] = '\0';
break;
default:
goto user_error;
Expand Down
1 change: 0 additions & 1 deletion src/tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include <arpa/inet.h>
#include <fcntl.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <netdb.h>
#if HAVE_PTY_H
#include <pty.h>
Expand Down

0 comments on commit 644f8c9

Please sign in to comment.