[lvm-devel] master - debug: capture internal error for too long resource name
Zdenek Kabelac
zkabelac at sourceware.org
Mon Feb 19 15:46:28 UTC 2018
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e7f1329cae118ccbfded213eee4895d99d79120b
Commit: e7f1329cae118ccbfded213eee4895d99d79120b
Parent: c3bb2b29d441f27d7e1d88f71d934ba8c955b26d
Author: Zdenek Kabelac <zkabelac at redhat.com>
AuthorDate: Mon Feb 19 15:30:55 2018 +0100
Committer: Zdenek Kabelac <zkabelac at redhat.com>
CommitterDate: Mon Feb 19 16:45:10 2018 +0100
debug: capture internal error for too long resource name
Should never happen, so just put in internal error instead of silently
passing some shortened resource name.
---
lib/locking/locking.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index d61aa35..1e1be56 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -264,7 +264,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
}
if ((is_orphan_vg(resource) || is_global_vg(resource)) && (flags & LCK_CACHE)) {
- log_error(INTERNAL_ERROR "P_%s referenced", resource);
+ log_error(INTERNAL_ERROR "P_%s referenced.", resource);
goto out;
}
@@ -358,8 +358,10 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, const str
return 0;
}
- strncpy(resource, vol, sizeof(resource) - 1);
- resource[sizeof(resource) - 1] = '\0';
+ if (!dm_strncpy(resource, vol, sizeof(resource))) {
+ log_error(INTERNAL_ERROR "Resource name %s is too long.", vol);
+ return 0;
+ }
if (!_lock_vol(cmd, resource, flags, lv_op, lv))
return_0;
More information about the lvm-devel
mailing list