From owner-freebsd-arch Sun Jan 20 21:26:27 2002 Delivered-To: freebsd-arch@freebsd.org Received: from lennier.cc.vt.edu (lennier.cc.vt.edu [198.82.162.213]) by hub.freebsd.org (Postfix) with ESMTP id 7BC7B37B400 for ; Sun, 20 Jan 2002 21:26:07 -0800 (PST) Received: from dagger.cc.vt.edu (IDENT:mirapoint@dagger-lb.cc.vt.edu [10.1.1.11]) by lennier.cc.vt.edu (8.11.4/8.11.4) with ESMTP id g0L5Q4C442098; Mon, 21 Jan 2002 00:26:04 -0500 (EST) Received: from enterprise.muriel.penguinpowered.com (hc6526444.dhcp.vt.edu [198.82.100.68]) by dagger.cc.vt.edu (Mirapoint) with ESMTP id ASX47627; Mon, 21 Jan 2002 00:26:03 -0500 (EST) Message-ID: X-Mailer: XFMail 1.5.2 on FreeBSD X-Priority: 3 (Normal) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="_=XFMail.1.5.2.FreeBSD:20020121002603:272=_"; micalg=pgp-md5; protocol="application/pgp-signature" In-Reply-To: <20020120224344.A15845@straylight.oblivion.bg> Date: Mon, 21 Jan 2002 00:26:03 -0500 (EST) From: Mike Heffner To: Peter Pentchev Subject: Re: sftp, glob(3) and GLOB_NOMATCH - urgent before 4.5-R! Cc: djm@mindrot.org, arch@FreeBSD.ORG Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 Blacksburg, VA 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