Ticket #4575: 0001-vfs-fix-tempdir-path-building-to-account-for-trailin.patch

File 0001-vfs-fix-tempdir-path-building-to-account-for-trailin.patch, 1.2 KB (added by zaytsev, 3 weeks ago)
  • lib/vfs/interface.c

    From ca07448759501684b04cce678cee53aa8e2a0c68 Mon Sep 17 00:00:00 2001
    From: "Yury V. Zaytsev" <yury@shurup.com>
    Date: Thu, 29 Aug 2024 12:13:40 +0200
    Subject: [PATCH] vfs: fix tempdir path building to account for trailing slash
     on macOS
    
    Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
    ---
     lib/vfs/interface.c | 6 +++++-
     1 file changed, 5 insertions(+), 1 deletion(-)
    
    diff --git a/lib/vfs/interface.c b/lib/vfs/interface.c
    index 63bbddec6..384705120 100644
    a b mc_tmpdir (void) 
    775775    static const char *tmpdir = NULL; 
    776776    const char *sys_tmp; 
    777777    struct stat st; 
     778    gchar* template; 
    778779 
    779780    /* Check if already correctly initialized */ 
    780781    if (tmpdir != NULL && lstat (tmpdir, &st) == 0 && S_ISDIR (st.st_mode) && 
    mc_tmpdir (void) 
    789790            sys_tmp = TMPDIR_DEFAULT; 
    790791    } 
    791792 
    792     g_snprintf (buffer, sizeof (buffer), "%s/mc-XXXXXX", sys_tmp); 
     793    template = g_build_filename (sys_tmp, "mc-XXXXXX", (char *) NULL); 
     794    g_strlcpy(buffer, template, sizeof (buffer)); 
     795    g_free(template); 
     796 
    793797    tmpdir = g_mkdtemp (buffer); 
    794798    if (tmpdir != NULL) 
    795799        g_setenv ("MC_TMPDIR", tmpdir, TRUE);