summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2021-10-14 23:31:21 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2021-10-14 23:33:26 +0200
commit7e346ee2a5cd520fc038dda7451360bbe67e629f (patch)
tree1f3546f10a76df22ee2f7d46a228bf94a34c48d7
parentc38473548e546c8e94d41587714f350a11362c84 (diff)
downloadlvm2-7e346ee2a5cd520fc038dda7451360bbe67e629f.tar.gz
archiving: update refactoring
Commit 5ea426e65628218569ede461312d80ba5d1c50fb handled case with file path without '/' incorrectly - there is valid use-case so switch 'log_error()' to valid code branch.
-rw-r--r--lib/format_text/archive.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/format_text/archive.c b/lib/format_text/archive.c
index 740129df0..c9c4f2265 100644
--- a/lib/format_text/archive.c
+++ b/lib/format_text/archive.c
@@ -373,21 +373,21 @@ int archive_list_file(struct cmd_context *cmd, const char *file)
}
if (!(af.name = strrchr(file, '/'))) {
- log_error("No '/' in file path %s found.", file);
- return 0;
- }
+ af.name = file;
+ path[0] = 0;
+ } else {
+ len = (size_t)(af.name - file);
- len = (size_t)(af.name - file);
+ if (len >= sizeof(path)) {
+ log_error(INTERNAL_ERROR "Passed file path name %s is too long.", file);
+ return 0;
+ }
- if (len >= sizeof(path)) {
- log_error(INTERNAL_ERROR "Passed file path name %s is too long.", file);
- return 0;
+ memcpy(path, file, len);
+ path[len] = 0;
+ af.name++; /* jump over '/' */
}
- memcpy(path, file, len);
- path[len] = 0;
- af.name++; /* jump over '/' */
-
_display_archive(cmd, path, &af);
return 1;