Skip to content

Commit 644f8c9

Browse files
Get rid of FIELD_SIZE
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.
1 parent 9ffb78c commit 644f8c9

5 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ int load_config(struct vpn_config *cfg, const char *filename)
268268
cfg->password[PASSWORD_SIZE] = '\0';
269269
cfg->password_set = 1;
270270
} else if (strcmp(key, "otp") == 0) {
271-
strncpy(cfg->otp, val, FIELD_SIZE);
272-
cfg->otp[FIELD_SIZE] = '\0';
271+
strncpy(cfg->otp, val, OTP_SIZE);
272+
cfg->otp[OTP_SIZE] = '\0';
273273
} else if (strcmp(key, "otp-prompt") == 0) {
274274
free(cfg->otp_prompt);
275275
cfg->otp_prompt = strdup(val);

src/config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ struct x509_digest {
5858
char data[SHA256STRLEN];
5959
};
6060

61-
#define FIELD_SIZE 64
6261
#define GATEWAY_HOST_SIZE 253
6362
#define USERNAME_SIZE 64
6463
#define PASSWORD_SIZE 256
64+
#define OTP_SIZE 64
6565
#define REALM_SIZE 63
6666

6767
/*
@@ -88,7 +88,7 @@ struct vpn_config {
8888
char username[USERNAME_SIZE + 1];
8989
char password[PASSWORD_SIZE + 1];
9090
int password_set;
91-
char otp[FIELD_SIZE + 1];
91+
char otp[OTP_SIZE + 1];
9292
char *otp_prompt;
9393
unsigned int otp_delay;
9494
int no_ftm_push;

src/http.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ static int try_otp_auth(struct tunnel *tunnel, const char *buffer,
584584
v = NULL;
585585
if (cfg->otp[0] == '\0') {
586586
read_password(cfg->pinentry, "otp",
587-
p, cfg->otp, FIELD_SIZE);
587+
p, cfg->otp, OTP_SIZE);
588588
if (cfg->otp[0] == '\0') {
589589
log_error("No OTP specified\n");
590590
return 0;
@@ -730,7 +730,7 @@ int auth_log_in(struct tunnel *tunnel)
730730
// Prompt for 2FA token
731731
read_password(cfg->pinentry, "2fa",
732732
"Two-factor authentication token: ",
733-
cfg->otp, FIELD_SIZE);
733+
cfg->otp, OTP_SIZE);
734734

735735
if (cfg->otp[0] == '\0') {
736736
log_error("No token specified\n");

src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,8 @@ int main(int argc, char **argv)
524524
*optarg++ = '*'; // nuke it
525525
break;
526526
case 'o':
527-
strncpy(cli_cfg.otp, optarg, FIELD_SIZE);
528-
cli_cfg.otp[FIELD_SIZE] = '\0';
527+
strncpy(cli_cfg.otp, optarg, OTP_SIZE);
528+
cli_cfg.otp[OTP_SIZE] = '\0';
529529
break;
530530
default:
531531
goto user_error;

src/tunnel.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#include <arpa/inet.h>
4646
#include <fcntl.h>
4747
#include <ifaddrs.h>
48-
#include <net/if.h>
4948
#include <netdb.h>
5049
#if HAVE_PTY_H
5150
#include <pty.h>

0 commit comments

Comments
 (0)