From fb7570709a623b6da7ab88c74cfc498174ccfc33 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen Date: Mon, 6 Nov 2023 15:22:23 +0200 Subject: [PATCH] Extend username limit to 128-1 --- common/network/websocket.c | 3 +-- common/network/websocket.h | 3 ++- common/rfb/VNCSConnectionST.cxx | 2 +- common/rfb/VNCSConnectionST.h | 4 +++- unix/kasmvncpasswd/kasmpasswd.h | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common/network/websocket.c b/common/network/websocket.c index 6aa6e90..706c342 100644 --- a/common/network/websocket.c +++ b/common/network/websocket.c @@ -33,7 +33,6 @@ #include /* sha1 hash */ #include "websocket.h" #include "jsonescape.h" -#include "kasmpasswd.h" #include /* @@ -1756,7 +1755,7 @@ ws_ctx_t *do_handshake(int sock, char * const ip) { } unsigned char owner = 0; - char inuser[32] = "-"; + char inuser[USERNAME_LEN] = "-"; if (!settings.disablebasicauth) { const char *hdr = strstr(handshake, "Authorization: Basic "); if (!hdr) { diff --git a/common/network/websocket.h b/common/network/websocket.h index b5fc674..e9e8153 100644 --- a/common/network/websocket.h +++ b/common/network/websocket.h @@ -2,6 +2,7 @@ #include #include "GetAPIEnums.h" #include "datelog.h" +#include "kasmpasswd.h" #define BUFSIZE 65536 #define DBUFSIZE (BUFSIZE * 3) / 4 - 20 @@ -57,7 +58,7 @@ typedef struct { char *tin_buf; char *tout_buf; - char user[32]; + char user[USERNAME_LEN]; char ip[64]; } ws_ctx_t; diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index c7eef87..511e12c 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -89,7 +89,7 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s, user[0] = '\0'; const char *at = strrchr(peerEndpoint.buf, '@'); - if (at && at - peerEndpoint.buf > 1 && at - peerEndpoint.buf < 32) { + if (at && at - peerEndpoint.buf > 1 && at - peerEndpoint.buf < USERNAME_LEN) { memcpy(user, peerEndpoint.buf, at - peerEndpoint.buf); user[at - peerEndpoint.buf] = '\0'; } diff --git a/common/rfb/VNCSConnectionST.h b/common/rfb/VNCSConnectionST.h index 654f44e..24d1863 100644 --- a/common/rfb/VNCSConnectionST.h +++ b/common/rfb/VNCSConnectionST.h @@ -35,6 +35,8 @@ #include #include +#include "kasmpasswd.h" + namespace rfb { class VNCServerST; @@ -318,7 +320,7 @@ namespace rfb { rdr::U64 bstats_total[BS_NUM]; struct timeval connStart; - char user[32]; + char user[USERNAME_LEN]; char kasmpasswdpath[4096]; bool needsPermCheck; diff --git a/unix/kasmvncpasswd/kasmpasswd.h b/unix/kasmvncpasswd/kasmpasswd.h index c6cbed0..ada8d03 100644 --- a/unix/kasmvncpasswd/kasmpasswd.h +++ b/unix/kasmvncpasswd/kasmpasswd.h @@ -6,7 +6,7 @@ extern "C" { #endif struct kasmpasswd_entry_t { - char user[32]; + char user[128]; char password[128]; unsigned char read : 1; unsigned char write : 1;