main - cov: make read buffer obviously zero ended
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=752a9ec4b44198554b9f998ed6e4a837878fc49f Commit: 752a9ec4b44198554b9f998ed6e4a837878fc49f Parent: 6c87e98ee367e1ff410470c09e6131697f0a7660 Author: Zdenek Kabelac <[email protected]> AuthorDate: Mon Sep 20 01:57:06 2021 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Sep 20 14:26:09 2021 +0200
cov: make read buffer obviously zero ended
Coverity doesn't get the idea from memset() here.
--- lib/config/config.c | 2 +- tools/pvck.c | 5 ++--- tools/pvscan.c | 1 + 3 files changed, 4 insertions(+), 4 deletions(-)
lib/config/config.c +1 -1
@@ -522,7 +522,7 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_rif (!(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 ; }
tools/pvck.c +2 -3
@@ -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 *mffree (text_buf); goto out; } - - text_size +=1 ;/* null terminating byte */ + text_buf[text_size++] =0 ;/* null terminating byte */ if (close (fd)) stack;
tools/pvscan.c +1 -0
@@ -223,6 +223,7 @@ static int _online_pvid_file_read(char *path, int *major, int *minor, char *vgnalog_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);