master - debug: capture internal error for too long resource name
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e7f1329cae118ccbfded213eee4895d99d79120b Commit: e7f1329cae118ccbfded213eee4895d99d79120b Parent: c3bb2b29d441f27d7e1d88f71d934ba8c955b26d Author: Zdenek Kabelac <[email protected]> AuthorDate: Mon Feb 19 15:30:55 2018 +0100 Committer: Zdenek Kabelac <[email protected]> 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(-)
lib/locking/locking.c +5 -3
@@ -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 strreturn 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;