master - coverity: check for zero length buffer
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=eaaae185b7870372298502d076defab2c3486ed3 Commit: eaaae185b7870372298502d076defab2c3486ed3 Parent: b08eb91df132e84fa41b4cf06707629b2c5c895e Author: Zdenek Kabelac <[email protected]> AuthorDate: Tue Feb 23 19:54:19 2016 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Tue Feb 23 21:40:16 2016 +0100
coverity: check for zero length buffer
When get_shared_library_path() would got zero length buffer, it could have underflow in size calc later.
So just put extra small check for this case.
--- lib/misc/sharedlib.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
lib/misc/sharedlib.c +4 -1
@@ -27,10 +27,13 @@ void get_shared_library_path(struct cmd_context *cmd, const char *libname, {struct stat info; +if (!path_len) +return ; +/* If libname doesn't begin with '/' then use lib_dir/libname, * if present */ if (libname[0 ] =='/' || - (!cmd->lib_dir && + (!cmd->lib_dir && !(cmd->lib_dir =find_config_tree_str (cmd, global_library_dir_CFG,NULL ))) || (dm_snprintf (path, path_len,"%s/%s" , cmd->lib_dir, libname) ==-1 ) ||stat (path, &info) ==-1 ) {