diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2018-02-19 15:30:55 +0100 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2018-02-19 16:45:10 +0100 |
commit | e7f1329cae118ccbfded213eee4895d99d79120b (patch) | |
tree | c63ce33e66ae8b0c315359ea6192855a16a98d6d /lib/locking/locking.c | |
parent | c3bb2b29d441f27d7e1d88f71d934ba8c955b26d (diff) | |
download | lvm2-e7f1329cae118ccbfded213eee4895d99d79120b.tar.gz |
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.
Diffstat (limited to 'lib/locking/locking.c')
-rw-r--r-- | 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 d61aa35ad..1e1be56d5 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; |