Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Jan 2002 00:26:03 -0500 (EST)
From:      Mike Heffner <mheffner@vt.edu>
To:        Peter Pentchev <roam@ringlet.net>
Cc:        djm@mindrot.org, arch@FreeBSD.ORG
Subject:   Re: sftp, glob(3) and GLOB_NOMATCH - urgent before 4.5-R!
Message-ID:  <XFMail.20020121002603.mheffner@vt.edu>
In-Reply-To: <20020120224344.A15845@straylight.oblivion.bg>

next in thread | previous in thread | raw e-mail | index | archive | help
This message is in MIME format
--_=XFMail.1.5.2.FreeBSD:20020121002603:272=_
Content-Type: text/plain; charset=us-ascii

Well, IEEE 1003.1-2001 states that glob(3) should return GLOB_NOMATCH,
but, as noticed, this hasn't been implemented in glob(3) yet. IMO, since
we are so close to 4.5R, we should commit the local change in the PR to
OpenSSH and worry about implementing GLOB_NOMATCH (and the other options
that are lacking in glob(3)) after 4.5R. The change in the PR will be
forwards compatible when it comes to implementing GLOB_NOMATCH. In
anycase, the (untested) patch below should be enough to implement
GLOB_NOMATCH.

On 20-Jan-2002 Peter Pentchev wrote:
| Hi,
| 
| In FreeBSD PR 34019, the submitter discusses an sftp core dump when
| a nonexistent file is uploaded.  I found out that the same bug
| exists on uploading, and that it is caused by the fact that sftp
| expects glob(3) to error out when no matches are found.  I opened
| up an OpenSSH problem report (bug id 73 in the mindrot.org database)
| and soon afterwards, I received the attached reply, which was CC'd
| to our GNATS.
| 
| So.. somebody who is acquainted with standards, compatiblity, POLA
| and stuff - how do we go about this?  Do we commit the fix in the
| audit trail of PR 34019, thus making another local change to OpenSSH?
| Do we change glob(3)'s behavior to return GLOB_NOMATCH?  Or do we ship
| 4.5 with a known bad sftp client? :)  I've CC'd Damien Miller (thanks
| for the fast response!) so that the OpenSSH folks are also aware of
| this discussion.
| 


Mike

-- 
  Mike Heffner   <mheffner@[acm.]vt.edu>
  Blacksburg, VA     <mikeh@FreeBSD.org>



Index: include/glob.h
===================================================================
RCS file: /home/ncvs/src/include/glob.h,v
retrieving revision 1.5
diff -u -r1.5 glob.h
--- include/glob.h      29 Jul 2001 00:52:33 -0000      1.5
+++ include/glob.h      21 Jan 2002 05:15:47 -0000
@@ -82,8 +82,10 @@
 /* backwards compatibility, this is the old name for this option */
 #define GLOB_MAXPATH   GLOB_LIMIT
 
+/* Error values returned by glob(3) */
 #define        GLOB_NOSPACE    (-1)    /* Malloc call failed. */
 #define        GLOB_ABEND      (-2)    /* Unignored error. */
+#define        GLOB_NOMATCH    (-3)    /* No match and GLOB_NOCHECK was
not set. */
 
 __BEGIN_DECLS
 int    glob __P((const char *, int, int (*)(const char *, int), glob_t
*));
Index: lib/libc/gen/glob.3
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/glob.3,v
retrieving revision 1.20
diff -u -r1.20 glob.3
--- lib/libc/gen/glob.3 1 Oct 2001 16:08:51 -0000       1.20
+++ lib/libc/gen/glob.3 21 Jan 2002 05:15:47 -0000
@@ -392,6 +392,10 @@
 was set or
 .Fa \*(lp*errfunc\*(rp\*(lp\*(rp
 returned non-zero.
+.It Dv GLOB_NOMATCH
+The pattern did not match a pathname and
+.Dv GLOB_NOCHECK
+was not set.
 .El
 .Pp
 The arguments
Index: lib/libc/gen/glob.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/glob.c,v
retrieving revision 1.18
diff -u -r1.18 glob.c
--- lib/libc/gen/glob.c 29 Jul 2001 00:52:33 -0000      1.18
+++ lib/libc/gen/glob.c 21 Jan 2002 05:15:48 -0000
@@ -493,12 +493,15 @@
         * and the pattern did not contain any magic characters
         * GLOB_NOMAGIC is there just for compatibility with csh.
         */
-       if (pglob->gl_pathc == oldpathc &&
-           ((pglob->gl_flags & GLOB_NOCHECK) ||
-             ((pglob->gl_flags & GLOB_NOMAGIC) &&
-              !(pglob->gl_flags & GLOB_MAGCHAR))))
-               return(globextend(pattern, pglob, limit));
-       else if (!(pglob->gl_flags & GLOB_NOSORT))
+       if (pglob->gl_pathc == oldpathc) {
+               if ((pglob->gl_flags & GLOB_NOCHECK) ||
+                   ((pglob->gl_flags & GLOB_NOMAGIC) &&
+                       !(pglob->gl_flags & GLOB_MAGCHAR)))
+                       return(globextend(pattern, pglob, limit));
+               else
+                       return(GLOB_NOMATCH);
+       }
+       if (!(pglob->gl_flags & GLOB_NOSORT))
                qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
                    pglob->gl_pathc - oldpathc, sizeof(char *), compare);
        return(0);


--_=XFMail.1.5.2.FreeBSD:20020121002603:272=_
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE8S6ZqFokZQs3sv5kRAvQCAKCIWOjv7qswCBlHMMF5ZjF+B/qk7ACfZGVb
9xU3Ez2+5yz702nxWw82fKY=
=jcDU
-----END PGP SIGNATURE-----

--_=XFMail.1.5.2.FreeBSD:20020121002603:272=_--
End of MIME message

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20020121002603.mheffner>