Ticket #4620: mc-4620-config_parser_c-fix-use-after-free.patch

File mc-4620-config_parser_c-fix-use-after-free.patch, 1.4 KB (added by and, 6 hours ago)
  • src/vfs/sftpfs/config_parser.c

    From cda5c62926a8a8dccfcacb47e7ea4ab610987a0f Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Wed, 18 Dec 2024 21:00:00 +0000
    Subject: [PATCH] (config_parser.c) fix use-after-free
    
    Fix Use-after-free in sftpfs_fill_connection_data_from_config()
    
    Found by Clang-19 Static Analyzer
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/vfs/sftpfs/config_parser.c | 7 ++++++-
     1 file changed, 6 insertions(+), 1 deletion(-)
    
    diff --git a/src/vfs/sftpfs/config_parser.c b/src/vfs/sftpfs/config_parser.c
    index 622ac3266..5e5741cfc 100644
    a b sftpfs_fill_connection_data_from_config (struct vfs_s_super *super, GError **mce 
    374374{ 
    375375    sftpfs_super_t *sftpfs_super = SFTP_SUPER (super); 
    376376    sftpfs_ssh_config_entity_t *config_entity; 
     377    char *tmp_str = NULL; 
    377378 
    378379    mc_return_if_error (mcerror); 
    379380 
    sftpfs_fill_connection_data_from_config (struct vfs_s_super *super, GError **mce 
    393394 
    394395    if (config_entity->real_host != NULL) 
    395396    { 
     397        tmp_str = g_strdup (super->path_element->host); 
    396398        g_free (super->path_element->host); 
     399 
    397400        super->path_element->host = 
    398             sftpsfs_expand_hostname (super->path_element->host, config_entity->real_host); 
     401            sftpsfs_expand_hostname (tmp_str, config_entity->real_host); 
     402 
     403        g_free (tmp_str); 
    399404    } 
    400405 
    401406    if (config_entity->identity_file != NULL)