Ticket #4572: mc-4572-ftpfs.c-fix-error-handling.patch

File mc-4572-ftpfs.c-fix-error-handling.patch, 1.1 KB (added by and, 5 days ago)
  • src/vfs/ftpfs/ftpfs.c

    From 09dbef88bfc4286615dc436ced85f629179f857a Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Mon, 16 Dec 2024 22:00:00 +0000
    Subject: [PATCH] (ftpfs.c) fix error handling
    
    Assuming that 'close' is successful; 'errno' becomes undefined after the call
    
    Found by Clang-19 Static Analyzer
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/vfs/ftpfs/ftpfs.c | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/src/vfs/ftpfs/ftpfs.c b/src/vfs/ftpfs/ftpfs.c
    index 6eb9c2aaf..1240160ba 100644
    a b ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super) 
    933933            break; 
    934934 
    935935        me->verrno = errno; 
    936         close (my_socket); 
     936        e = close (my_socket); 
    937937 
    938         if (errno == EINTR && tty_got_interrupt ()) 
     938        if (e < 0 && errno == EINTR && tty_got_interrupt ()) 
    939939            vfs_print_message ("%s", _("ftpfs: connection interrupted by user")); 
    940940        else if (res->ai_next == NULL) 
    941941            vfs_print_message (_("ftpfs: connection to server failed: %s"),