rpmQueryVerify: don't parse file argument

This commit is contained in:
Дмитрий Левин 2002-12-09 14:30:30 +00:00
parent 8769e44cd0
commit 2b157ba674

View File

@ -586,36 +586,24 @@ int rpmQueryVerify(QVA_t qva, rpmQVSources source, const char * arg,
int rc; int rc;
int isSource; int isSource;
int retcode = 0; int retcode = 0;
const char ** av = NULL;
char * end = NULL; char * end = NULL;
const char * s; const char * s;
int i; int i;
switch (source) { switch (source) {
case RPMQV_RPM: case RPMQV_RPM:
{ int ac = 0; {
const char * fileURL = NULL; const char * fileURL = arg;
rpmRC rpmrc; rpmRC rpmrc;
rc = rpmGlob(arg, &ac, &av);
if (rc) return 1;
restart:
for (i = 0; i < ac; i++) {
FD_t fd;
fileURL = _free(fileURL);
fileURL = av[i];
av[i] = NULL;
/* Try to read the header from a package file. */ /* Try to read the header from a package file. */
fd = Fopen(fileURL, "r.ufdio"); FD_t fd = Fopen(fileURL, "r.ufdio");
if (fd == NULL || Ferror(fd)) { if (fd == NULL || Ferror(fd)) {
rpmError(RPMERR_OPEN, _("open of %s failed: %s\n"), fileURL, rpmError(RPMERR_OPEN, _("open of %s failed: %s\n"), fileURL,
Fstrerror(fd)); Fstrerror(fd));
if (fd) (void) Fclose(fd); if (fd) (void) Fclose(fd);
retcode = 1; retcode = 1;
/*@loopbreak@*/ break; break;
} }
/*@-mustmod@*/ /* LCL: segfault. */ /*@-mustmod@*/ /* LCL: segfault. */
@ -626,54 +614,21 @@ restart:
if (!(rpmrc == RPMRC_OK || rpmrc == RPMRC_BADMAGIC)) { if (!(rpmrc == RPMRC_OK || rpmrc == RPMRC_BADMAGIC)) {
rpmError(RPMERR_QUERY, _("query of %s failed\n"), fileURL); rpmError(RPMERR_QUERY, _("query of %s failed\n"), fileURL);
retcode = 1; retcode = 1;
/*@loopbreak@*/ break; break;
} }
if (rpmrc == RPMRC_OK && h == NULL) { if (rpmrc == RPMRC_OK && h == NULL) {
rpmError(RPMERR_QUERY, rpmError(RPMERR_QUERY,
_("old format source packages cannot be queried\n")); _("old format source packages cannot be queried\n"));
retcode = 1; retcode = 1;
/*@loopbreak@*/ break; break;
} }
/* Query a package file. */ /* Query a package file. */
if (rpmrc == RPMRC_OK) { if (rpmrc == RPMRC_OK) {
retcode = showPackage(qva, rpmdb, h); retcode = showPackage(qva, rpmdb, h);
h = headerFree(h); h = headerFree(h);
continue; break;
} }
/* Try to read a package manifest. */
fd = Fopen(fileURL, "r.fpio");
if (fd == NULL || Ferror(fd)) {
rpmError(RPMERR_OPEN, _("open of %s failed: %s\n"), fileURL,
Fstrerror(fd));
if (fd) (void) Fclose(fd);
retcode = 1;
/*@loopbreak@*/ break;
}
/* Read list of packages from manifest. */
retcode = rpmReadPackageManifest(fd, &ac, &av);
if (retcode) {
rpmError(RPMERR_MANIFEST, _("%s: read manifest failed: %s\n"),
fileURL, Fstrerror(fd));
retcode = 1;
}
(void) Fclose(fd);
/* If successful, restart the query loop. */
if (retcode == 0)
goto restart;
/*@loopbreak@*/ break;
}
fileURL = _free(fileURL);
if (av) {
for (i = 0; i < ac; i++)
av[i] = _free(av[i]);
av = _free(av);
}
} break; } break;
case RPMQV_SPECFILE: case RPMQV_SPECFILE:
@ -723,6 +678,7 @@ restart:
rpmError(RPMERR_QUERYINFO, _("no packages\n")); rpmError(RPMERR_QUERYINFO, _("no packages\n"));
retcode = 1; retcode = 1;
} else { } else {
const char **av;
for (av = (const char **) arg; av && *av; av++) { for (av = (const char **) arg; av && *av; av++) {
if (!rpmdbSetIteratorRE(mi, RPMTAG_NAME, RPMMIRE_DEFAULT, *av)) if (!rpmdbSetIteratorRE(mi, RPMTAG_NAME, RPMMIRE_DEFAULT, *av))
continue; continue;