summaryrefslogtreecommitdiffstats
path: root/libdm/libdm-common.c
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2012-02-08 11:05:04 +0000
committerZdenek Kabelac <zkabelac@redhat.com>2012-02-08 11:05:04 +0000
commit5dfd77538405a3fdb0793fe52d55a5ea20dcdbb0 (patch)
treec713b18298769d2895220a01d29ddbe8c48ea8ca /libdm/libdm-common.c
parentcd4c26a27fd425755f9f4c7d2318942a184f7390 (diff)
downloadlvm2-5dfd77538405a3fdb0793fe52d55a5ea20dcdbb0.tar.gz
lvm2-5dfd77538405a3fdb0793fe52d55a5ea20dcdbb0.tar.xz
lvm2-5dfd77538405a3fdb0793fe52d55a5ea20dcdbb0.zip
Ensure strncpy() function always ends with '\0'
Since last character needs to be \0 for string, pass buffer size smaller by 1 byte.
Diffstat (limited to 'libdm/libdm-common.c')
-rw-r--r--libdm/libdm-common.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index a4a351ed..2fb5e5e5 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -706,7 +706,7 @@ int get_dev_node_read_ahead(const char *dev_name, uint32_t major, uint32_t minor
if ((fd = open(_path0, O_RDONLY, 0)) != -1) {
/* Reading from sysfs, expecting number\n */
- if ((len = read(fd, buf, sizeof(buf))) < 1) {
+ if ((len = read(fd, buf, sizeof(buf) - 1)) < 1) {
log_sys_error("read", _path0);
r = 0;
} else {
@@ -1256,7 +1256,7 @@ static int _sysfs_get_kernel_name(uint32_t major, uint32_t minor, char *buf, siz
goto error;
}
- if ((size = readlink(sysfs_path, temp_buf, PATH_MAX)) < 0) {
+ if ((size = readlink(sysfs_path, temp_buf, PATH_MAX - 1)) < 0) {
if (errno != ENOENT)
log_sys_error("readlink", sysfs_path);
else