mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
coverity: fix memory access
Commit 52e0d0db44
introduced regression
as code may access buf[0 - 1].
Reorder code to first remove '\n' and then check buffer size for
empty.
This commit is contained in:
parent
556eba1835
commit
cbf99be43a
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.151 -
|
Version 2.02.151 -
|
||||||
=================================
|
=================================
|
||||||
|
Fix memory access for empty sysfs values (2.02.149).
|
||||||
Disable lvmetad when lvm1 metadata is seen, so commands revert to scanning.
|
Disable lvmetad when lvm1 metadata is seen, so commands revert to scanning.
|
||||||
Suppress errors when snapshot merge gets delayed because volume is in use.
|
Suppress errors when snapshot merge gets delayed because volume is in use.
|
||||||
Avoid internal snapshot LV names in messages.
|
Avoid internal snapshot LV names in messages.
|
||||||
|
@ -379,17 +379,13 @@ static int _get_sysfs_value(const char *path, char *buf, size_t buf_size, int er
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(len = strlen(buf)) || (len == 1 && buf[0] == '\n')) {
|
if ((len = strlen(buf)) && buf[len - 1] == '\n')
|
||||||
if (error_if_no_value) {
|
buf[--len] = '\0';
|
||||||
log_error("_get_sysfs_value: %s: no value", path);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buf[len - 1] == '\n')
|
if (!len && error_if_no_value)
|
||||||
buf[len - 1] = '\0';
|
log_error("_get_sysfs_value: %s: no value", path);
|
||||||
|
else
|
||||||
r = 1;
|
r = 1;
|
||||||
out:
|
out:
|
||||||
if (fclose(fp))
|
if (fclose(fp))
|
||||||
log_sys_error("fclose", path);
|
log_sys_error("fclose", path);
|
||||||
|
Loading…
Reference in New Issue
Block a user