SDL: Use SDL string functions

From f2695856d6c552b16cdf2967bbef0548aa17e4f5 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 12 Feb 2024 19:51:48 -0800
Subject: [PATCH] Use SDL string functions

---
 src/filesystem/unix/SDL_sysfilesystem.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c
index c752d37f5e6a..937994af0d04 100644
--- a/src/filesystem/unix/SDL_sysfilesystem.c
+++ b/src/filesystem/unix/SDL_sysfilesystem.c
@@ -495,15 +495,14 @@ static char *xdg_user_dir_lookup (const char *type)
         return NULL;
 
     /* Special case desktop for historical compatibility */
-    if (SDL_strcmp(type, "DESKTOP") == 0)
-    {
-        user_dir = (char*) SDL_malloc(SDL_strlen(home_dir) +
-                                      SDL_strlen("/Desktop") + 1);
+    if (SDL_strcmp(type, "DESKTOP") == 0) {
+        size_t length = SDL_strlen(home_dir) + SDL_strlen("/Desktop") + 1;
+        user_dir = (char*) SDL_malloc(length);
         if (!user_dir)
             return NULL;
 
-        strcpy(user_dir, home_dir);
-        strcat(user_dir, "/Desktop");
+        SDL_strlcpy(user_dir, home_dir, length);
+        SDL_strlcat(user_dir, "/Desktop", length);
         return user_dir;
     }