mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-28 02:50:41 +03:00
cov: use check of snprintf result
Do validation in one go with snprintf() result, so there is no extra strlen() and uncheck possibly truncating snprintf() visible to coverity.
This commit is contained in:
parent
c5b4574729
commit
2b802ab413
@ -2918,12 +2918,11 @@ static struct lockspace *find_lockspace_name(char *ls_name)
|
||||
|
||||
static int vg_ls_name(const char *vg_name, char *ls_name)
|
||||
{
|
||||
if (strlen(vg_name) + 4 > MAX_NAME) {
|
||||
if (snprintf(ls_name, MAX_NAME, "%s%s", LVM_LS_PREFIX, vg_name) >= MAX_NAME) {
|
||||
log_error("vg name too long %s", vg_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(ls_name, MAX_NAME, "%s%s", LVM_LS_PREFIX, vg_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user