mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
cov: make read buffer obviously zero ended
Coverity doesn't get the idea from memset() here.
This commit is contained in:
parent
6c87e98ee3
commit
752a9ec4b4
@ -522,7 +522,7 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_r
|
||||
if (!(dev->flags & DEV_REGULAR) || size2)
|
||||
use_plain_read = 0;
|
||||
|
||||
if (!(buf = malloc(size + size2))) {
|
||||
if (!(buf = zalloc(size + size2))) {
|
||||
log_error("Failed to allocate circular buffer.");
|
||||
return 0;
|
||||
}
|
||||
|
@ -2955,7 +2955,7 @@ static int _read_metadata_file(struct cmd_context *cmd, struct metadata_file *mf
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!(text_buf = zalloc(text_size + 1)))
|
||||
if (!(text_buf = malloc(text_size + 1)))
|
||||
goto_out;
|
||||
|
||||
rv = read(fd, text_buf, text_size);
|
||||
@ -2964,8 +2964,7 @@ static int _read_metadata_file(struct cmd_context *cmd, struct metadata_file *mf
|
||||
free(text_buf);
|
||||
goto out;
|
||||
}
|
||||
|
||||
text_size += 1; /* null terminating byte */
|
||||
text_buf[text_size++] = 0; /* null terminating byte */
|
||||
|
||||
if (close(fd))
|
||||
stack;
|
||||
|
@ -223,6 +223,7 @@ static int _online_pvid_file_read(char *path, int *major, int *minor, char *vgna
|
||||
log_warn("No info in %s", path);
|
||||
return 0;
|
||||
}
|
||||
buf[rv] = 0; /* \0 terminated buffer */
|
||||
|
||||
if (sscanf(buf, "%d:%d", major, minor) != 2) {
|
||||
log_warn("No device numbers in %s", path);
|
||||
|
Loading…
Reference in New Issue
Block a user