From e369b3e68d253c6c4cf16686e84b1394c1344c2f Mon Sep 17 00:00:00 2001 From: dtechsrv Date: Sun, 31 Dec 2023 11:23:46 +0100 Subject: [PATCH] Fix possibility of a buffer overflow --- version.h | 2 +- vncserver.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/version.h b/version.h index 8d15050..1257faf 100644 --- a/version.h +++ b/version.h @@ -6,6 +6,6 @@ #define MAIN_VERSION_PATCH 0 #define MAIN_VERSION_BETA 0 -#define MAIN_VERSION_DATE "2023-12-29" +#define MAIN_VERSION_DATE "2023-12-31" #endif diff --git a/vncserver.c b/vncserver.c index 719c6d4..c72202e 100644 --- a/vncserver.c +++ b/vncserver.c @@ -184,9 +184,9 @@ int main(int argc, char **argv) { // Preset values from environment variables (However, the values specified in the arguments have priority.) if (getenv("VNC_SERVERNAME")) - strcpy(VNC_SERVERNAME, getenv("VNC_SERVERNAME")); + snprintf(VNC_SERVERNAME, sizeof(VNC_SERVERNAME), "%s", getenv("VNC_SERVERNAME")); if (getenv("VNC_PASSWORD")) - strcpy(VNC_PASSWORD, getenv("VNC_PASSWORD")); + snprintf(VNC_PASSWORD, sizeof(VNC_PASSWORD), "%s", getenv("VNC_PASSWORD")); if (getenv("VNC_PORT")) VNC_PORT = atoi(getenv("VNC_PORT")); @@ -206,11 +206,11 @@ int main(int argc, char **argv) { break; case 'n': i++; - strcpy(VNC_SERVERNAME,argv[i]); + snprintf(VNC_SERVERNAME, sizeof(VNC_SERVERNAME), "%s", argv[i]); break; case 'p': i++; - strcpy(VNC_PASSWORD,argv[i]); + snprintf(VNC_PASSWORD, sizeof(VNC_PASSWORD), "%s", argv[i]); break; case 'f': i++;