diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2010-09-08 13:31:25 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-09-08 13:31:25 +0300 |
commit | d960e8c18764f7206ad723963f407e960dfb8ad9 (patch) | |
tree | 4e4dabc26c9937515bc45ca35b6348a31211af52 | |
parent | be3c34dd15814d70a410b6fd646a2be7de14a1b5 (diff) | |
download | rpm-d960e8c18764f7206ad723963f407e960dfb8ad9.tar.gz rpm-d960e8c18764f7206ad723963f407e960dfb8ad9.tar.bz2 rpm-d960e8c18764f7206ad723963f407e960dfb8ad9.zip |
Differentiate between IO-errors and non-package "error" in rpmgi foo
- rpmgiLoadReadHeader() tested errno, but this isn't realiable:
rpmgiReadHeader() didn't differentiate between IO and other errors
properly so errno would be tested even when no errors (other than
not being a header) were present. This could be pretty much whatever
when no IO errors occurred in rpmgiReadHeader() but the file just
wasn't a header. With libio errno was typically EBADF, causing the
remaining code to execute, but without libio this happened to be
ENOENTRY, causing a silent failure on manifest query.
- This junk needs to die, really.
-rw-r--r-- | lib/rpmgi.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/rpmgi.c b/lib/rpmgi.c index 9b763ec37..fa9ed75f1 100644 --- a/lib/rpmgi.c +++ b/lib/rpmgi.c @@ -76,9 +76,10 @@ static rpmRC rpmgiLoadManifest(rpmgi gi, const char * path) * Return header from package. * @param gi generalized iterator * @param path file path - * @return header (NULL on failure) + * @retval hdrp header (NULL on failure) + * @return 1 if path could be opened, 0 if not */ -static Header rpmgiReadHeader(rpmgi gi, const char * path) +static int rpmgiReadHeader(rpmgi gi, const char * path, Header * hdrp) { FD_t fd = rpmgiOpen(path, "r.ufdio"); Header h = NULL; @@ -103,7 +104,8 @@ static Header rpmgiReadHeader(rpmgi gi, const char * path) } } - return h; + *hdrp = h; + return (fd != NULL); } /** @@ -120,13 +122,10 @@ static Header rpmgiLoadReadHeader(rpmgi gi) if (gi->argv != NULL && gi->argv[gi->i] != NULL) do { char * fn = gi->argv[gi->i]; - h = rpmgiReadHeader(gi, fn); + int rc = rpmgiReadHeader(gi, fn, &h); - if (h != NULL || gi->flags & RPMGI_NOMANIFEST) - break; - if (errno == ENOENT) { + if (h != NULL || (gi->flags & RPMGI_NOMANIFEST) || rc == 0) break; - } /* Not a header, so try for a manifest. */ gi->argv[gi->i] = NULL; /* Mark the insertion point */ |