break;
case QUERY_PATH:
- if (*arg != '/') {
- /* Using realpath on the arg isn't correct if the arg is a symlink,
- * especially if the symlink is a dangling link. What we should
- * instead do is use realpath() on `.' and then append arg to
- * it.
- */
- if (realpath(".", path) != NULL) {
- if (path[strlen(path)] != '/') {
- if (strncat(path, "/", sizeof(path) - strlen(path) - 1) == NULL) {
- fprintf(stderr, _("maximum path length exceeded\n"));
- return 1;
- }
- }
- /* now append the original file name to the real path */
- if (strncat(path, arg, sizeof(path) - strlen(path) - 1) == NULL) {
- fprintf(stderr, _("maximum path length exceeded\n"));
- return 1;
- }
- arg = path;
- }
- }
if (rpmdbFindByFile(db, arg, &matches)) {
int myerrno = 0;
if (access(arg, F_OK) != 0)
break;
case VERIFY_PATH:
- if (*arg != '/') {
- /* Using realpath on the arg isn't correct if the arg is a symlink,
- * especially if the symlink is a dangling link. What we should
- * instead do is use realpath() on `.' and then append arg to
- * it.
- */
- if (realpath(".", path) != NULL) {
- if (path[strlen(path)] != '/') {
- if (strncat(path, "/", sizeof(path) - strlen(path) - 1) == NULL) {
- fprintf(stderr, _("maximum path length exceeded\n"));
- return 1;
- }
- }
- /* now append the original file name to the real path */
- if (strncat(path, arg, sizeof(path) - strlen(path) - 1) == NULL) {
- fprintf(stderr, _("maximum path length exceeded\n"));
- return 1;
- }
- arg = path;
- }
- }
-
if (rpmdbFindByFile(db, arg, &matches)) {
fprintf(stderr, _("file %s is not owned by any package\n"),
arg);