diff --git a/network/netplay/netplay_common.c b/network/netplay/netplay_common.c index 329fa86957..8f008cd3b2 100644 --- a/network/netplay/netplay_common.c +++ b/network/netplay/netplay_common.c @@ -152,13 +152,13 @@ bool netplay_handshake_init_send(netplay_t *netplay, struct netplay_connection * struct nick_buf_s { uint32_t cmd[2]; - char nick[32]; + char nick[NETPLAY_NICK_LEN]; }; struct password_buf_s { uint32_t cmd[2]; - char password[64]; + char password[NETPLAY_PASS_HASH_LEN]; }; #define RECV(buf, sz) \ @@ -175,7 +175,7 @@ static netplay_t *handshake_password_netplay; static void handshake_password(void *ignore, const char *line) { struct password_buf_s password_buf; - char password[8+128]; /* 8 for salt, 128 for password */ + char password[8+NETPLAY_PASS_LEN]; /* 8 for salt, 128 for password */ uint32_t cmd[2]; netplay_t *netplay = handshake_password_netplay; struct netplay_connection *connection = &netplay->connections[0]; @@ -456,7 +456,7 @@ bool netplay_handshake_pre_nick(netplay_t *netplay, struct netplay_connection *c bool netplay_handshake_pre_password(netplay_t *netplay, struct netplay_connection *connection, bool *had_input) { struct password_buf_s password_buf, corr_password_buf; - char password[8+128]; /* 8 for salt, 128 for password */ + char password[8+NETPLAY_PASS_LEN]; /* 8 for salt */ ssize_t recvd; char msg[512]; diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index 1ec14c6f57..fd7fc39253 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -42,6 +42,10 @@ #define RARCH_DEFAULT_PORT 55435 #define RARCH_DEFAULT_NICK "Anonymous" +#define NETPLAY_NICK_LEN 32 +#define NETPLAY_PASS_LEN 128 +#define NETPLAY_PASS_HASH_LEN 64 /* length of a SHA-256 hash */ + #define PREV_PTR(x) ((x) == 0 ? netplay->buffer_size - 1 : (x) - 1) #define NEXT_PTR(x) ((x + 1) % netplay->buffer_size) @@ -246,7 +250,7 @@ struct netplay_connection struct sockaddr_storage addr; /* Nickname of peer */ - char nick[32]; + char nick[NETPLAY_NICK_LEN]; /* Salt associated with password transaction */ uint32_t salt; @@ -270,13 +274,13 @@ struct netplay bool is_server; /* Our nickname */ - char nick[32]; + char nick[NETPLAY_NICK_LEN]; /* TCP connection for listening (server only) */ int listen_fd; /* Password required to connect (server only) */ - char password[128]; + char password[NETPLAY_PASS_LEN]; /* Our player number */ uint32_t self_player;