From 7857dd0a9ae1097aa1a33d8cbb22058078eb1225 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 4 Jul 2017 12:00:43 -0700 Subject: [PATCH] GUACAMOLE-303: Ensure there is always space for the null terminator when normalizing. --- src/common-ssh/sftp.c | 2 +- src/protocols/rdp/rdp_fs.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common-ssh/sftp.c b/src/common-ssh/sftp.c index e0e029f6..8a53b264 100644 --- a/src/common-ssh/sftp.c +++ b/src/common-ssh/sftp.c @@ -77,7 +77,7 @@ static int guac_common_ssh_sftp_normalize_path(char* fullpath, strncpy(path_component_data, path, sizeof(path_component_data) - 1); /* Find path components within path */ - for (i = 0; i < sizeof(path_component_data); i++) { + for (i = 0; i < sizeof(path_component_data) - 1; i++) { /* If current character is a path separator, parse as component */ char c = path_component_data[i]; diff --git a/src/protocols/rdp/rdp_fs.c b/src/protocols/rdp/rdp_fs.c index 88668d82..ab48cc2f 100644 --- a/src/protocols/rdp/rdp_fs.c +++ b/src/protocols/rdp/rdp_fs.c @@ -622,10 +622,10 @@ int guac_rdp_fs_normalize_path(const char* path, char* abs_path) { path++; /* Copy path into component data for parsing */ - strncpy(path_component_data, path, GUAC_RDP_FS_MAX_PATH-1); + strncpy(path_component_data, path, sizeof(path_component_data) - 1); /* Find path components within path */ - for (i=0; i