[Bug 1541] New: sftp: the do_stat() failure is ignored for chown, chgrp ops. in parse_dispatch_command()

bugzilla-daemon at bugzilla.mindrot.org bugzilla-daemon at bugzilla.mindrot.org
Tue Nov 25 00:21:49 EST 2008


https://bugzilla.mindrot.org/show_bug.cgi?id=1541

           Summary: sftp: the do_stat() failure is ignored for chown,
                    chgrp ops. in parse_dispatch_command()
           Product: Portable OpenSSH
           Version: -current
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: trivial
          Priority: P5
         Component: sftp
        AssignedTo: unassigned-bugs at mindrot.org
        ReportedBy: anedvedicky at gmail.com


This is a realy small bug.

the code in parse_dispatch_command() looks as follows
@1186
        for (i = 0; g.gl_pathv[i] && !interrupted; i++) {
            if (!(aa = do_stat(conn, g.gl_pathv[i], 0))) {
                if (err != 0 && err_abort)
                    break;
                else
                    continue;
the err is always 0, once for loop is entered (this is guaranteed by
code in parse_dispatch_command()
so if do_stat() operation fails, the if (err != 0 && err_abort) is
still not satisfied and continue is always
executed. this prevents sftp client to bail out the function on the
first failure.

this will cause problem only in batchmode.


--- cut here to get patch ------
bash-3.2$ diff -u
/net/grok.czech/ws-local/onnv-clone/usr/src/cmd/ssh/sftp/sftp.c sftp.c
--- /net/grok.czech/ws-local/onnv-clone/usr/src/cmd/ssh/sftp/sftp.c    
Wed Oct 15 00:41:07 2008
+++ sftp.c      Fri Nov 21 17:05:48 2008
@@ -1185,18 +1185,26 @@
                remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g);
                for (i = 0; g.gl_pathv[i] && !interrupted; i++) {
                        if (!(aa = do_stat(conn, g.gl_pathv[i], 0))) {
-                               if (err != 0 && err_abort)
+                               if (err_abort) {
+                                       err = -1;
                                        break;
-                               else
+                               }
+                               else {
+                                       err = 0;
                                        continue;
+                               }
                        }
                        if (!(aa->flags & SSH2_FILEXFER_ATTR_UIDGID)) {
                                error("Can't get current ownership of "
                                    "remote file \"%s\"",
g.gl_pathv[i]);
-                               if (err != 0 && err_abort)
+                               if (err_abort) {
+                                       err = -1;
                                        break;
-                               else
+                               }
+                               else {
+                                       err = 0;
                                        continue;
+                               }
                        }
                        aa->flags &= SSH2_FILEXFER_ATTR_UIDGID;
                        if (cmdnum == I_CHOWN) {

-- 
Configure bugmail: https://bugzilla.mindrot.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list