Skip to content

Commit

Permalink
Fix possibility of a buffer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dtechsrv committed Dec 31, 2023
1 parent b7095cd commit e369b3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions vncserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand All @@ -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++;
Expand Down

0 comments on commit e369b3e

Please sign in to comment.