RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES rpm/rpmio/ rpmdav.c

From: Jeff Johnson <jbj@rpm5.org>
Date: Sat 09 Feb 2008 - 03:34:24 CET
Message-Id: <20080209023424.5F71E34847F@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: rpm                              Date:   09-Feb-2008 03:34:24
  Branch: HEAD                             Handle: 2008020902342301

  Modified files:
    rpm                     CHANGES
    rpm/rpmio               rpmdav.c

  Log:
    - jbj: dav{Stat,LStat,Opendir) return ENOENT with malformed URI (including
    	no pesky trailing /).
    - jbj: rpmdav: fix: supply davOpendir->davHEAD a statbuf to avoid tdir/tfts
    	segfaults on plain http. (only . and .. in directory).

  Summary:
    Revision    Changes     Path
    1.2158      +4  -0      rpm/CHANGES
    2.59        +24 -17     rpm/rpmio/rpmdav.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2157 -r1.2158 CHANGES
  --- rpm/CHANGES	8 Feb 2008 22:20:02 -0000	1.2157
  +++ rpm/CHANGES	9 Feb 2008 02:34:23 -0000	1.2158
  @@ -1,4 +1,8 @@
   5.0.0 -> 5.1a1:
  +    - jbj: dav{Stat,LStat,Opendir) return ENOENT with malformed URI (including
  +	no pesky trailing /).
  +    - jbj: rpmdav: fix: supply davOpendir->davHEAD a statbuf to avoid tdir/tfts
  +	segfaults on plain http. (only . and .. in directory).
       - jbj: tie tget/tdir/tglob/tfts to a rpmio "make check". much more to do ...
       - jbj: tweak up tglob debugging spew, add a Glob(3) stopwatch.
       - jbj: tweak up tget debugging spew, trick in a Stat(2) on path,
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmdav.c
  ============================================================================
  $ cvs diff -u -r2.58 -r2.59 rpmdav.c
  --- rpm/rpmio/rpmdav.c	8 Feb 2008 17:42:48 -0000	2.58
  +++ rpm/rpmio/rpmdav.c	9 Feb 2008 02:34:24 -0000	2.59
  @@ -895,7 +895,10 @@
       const char *value = NULL;
       int rc;
   
  -    st->st_mode = S_IFREG;
  +    /* XXX HACK: URI's with pesky trailing '/' are directories. */
  +    {	size_t nb = strlen(u->url);
  +	st->st_mode = (u->url[nb-1] == '/' ? S_IFDIR : S_IFREG);
  +    }
       st->st_blksize = 4 * 1024;	/* HACK correct for linux ext */
       st->st_size = -1;
       st->st_atime = -1;
  @@ -1479,11 +1482,13 @@
       char buf[1024];
       int rc = -1;
   
  -/* HACK: neon really wants collections with trailing '/' */
  +    if (path == NULL || *path == '\0') {
  +	errno = ENOENT;
  +	goto exit;
  +    }
       ctx = fetch_create_context(path, st);
       if (ctx == NULL) {
  -fprintf(stderr, "==> %s fetch_create_context ctx %p\n", "davStat", ctx);
  -/* HACK: errno = ??? */
  +	errno = ENOENT;		/* Note: ctx is NULL iff urlSplit() fails. */
   	goto exit;
       }
       rc = davNLST(ctx);
  @@ -1526,10 +1531,13 @@
       char buf[1024];
       int rc = -1;
   
  -/* HACK: neon really wants collections with trailing '/' */
  +    if (path == NULL || *path == '\0') {
  +	errno = ENOENT;
  +	goto exit;
  +    }
       ctx = fetch_create_context(path, st);
       if (ctx == NULL) {
  -/* HACK: errno = ??? */
  +	errno = ENOENT;		/* Note: ctx is NULL iff urlSplit() fails. */
   	goto exit;
       }
       rc = davNLST(ctx);
  @@ -1824,6 +1832,7 @@
   DIR * davOpendir(const char * path)
   {
       struct fetch_context_s * ctx;
  +    struct stat sb, *st = &sb; /* XXX HACK: davHEAD needs ctx->st. */
       DAVDIR avdir;
       struct dirent * dp;
       size_t nb;
  @@ -1833,22 +1842,20 @@
       int ac, nac;
       int rc;
   
  -    /* HACK: glob does not pass dirs with trailing '/' */
  -    nb = strlen(path)+1;
  -    if (path[nb-2] != '/') {
  -	char * npath = alloca(nb+1);
  -	*npath = '\0';
  -	(void) stpcpy( stpcpy(npath, path), "/");
  -	path = npath;
  -    }
  -
   if (_dav_debug < 0)
   fprintf(stderr, "*** davOpendir(%s)\n", path);
   
  +    /* Note: all URI's need pesky trailing '/' */
  +    if (path == NULL || *path == '\0' || path[strlen(path)-1] != '/') {
  +	errno = ENOENT;
  +	return NULL;
  +    }
  +
       /* Load DAV collection into argv. */
  -    ctx = fetch_create_context(path, NULL);
  +    /* XXX HACK: davHEAD needs ctx->st. */
  +    ctx = fetch_create_context(path, st);
       if (ctx == NULL) {
  -/* HACK: errno = ??? */
  +	errno = ENOENT;		/* Note: ctx is NULL iff urlSplit() fails. */
   	return NULL;
       }
       rc = davNLST(ctx);
  @@ .
Received on Sat Feb 9 03:34:24 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.