[gnome-remote-desktop] rdp-sam: Add space for the null terminator in filename



commit 2b2470282e93eeeac96d8e263d041f9f32641c1e
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Mon Aug 17 10:58:45 2020 +0200

    rdp-sam: Add space for the null terminator in filename
    
    strlen () does not count the null terminator as part of the actual
    string and therefore the filename of the SAM file currently does not
    have space for the null terminator allocated.
    While this didn't have caused a crash so far, fix this still by adding
    space for the null terminator.

 src/grd-rdp-sam.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/src/grd-rdp-sam.c b/src/grd-rdp-sam.c
index 6c52cf4..ce522a7 100644
--- a/src/grd-rdp-sam.c
+++ b/src/grd-rdp-sam.c
@@ -69,7 +69,8 @@ grd_rdp_sam_create_sam_file (const char *username,
   rdp_sam_file = g_malloc0 (sizeof (GrdRdpSAMFile));
 
   path = getenv ("XDG_RUNTIME_DIR");
-  filename = g_malloc0 (strlen (path) + strlen (grd_path) + strlen (template));
+  filename = g_malloc0 (strlen (path) + strlen (grd_path) +
+                        strlen (template) + 1);
   strcpy (filename, path);
   strcat (filename, grd_path);
   if (g_access (filename, F_OK))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]