master - cov: dm stats missed terminating null
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=20971f7034cbd329f873e08869bfb7acf3f1ac0e Commit: 20971f7034cbd329f873e08869bfb7acf3f1ac0e Parent: 77aa055e8a34eb7f0036b6240f3f93dc429c0c02 Author: Zdenek Kabelac <[email protected]> AuthorDate: Mon Oct 15 14:45:16 2018 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Oct 15 17:49:44 2018 +0200
cov: dm stats missed terminating null
Coverity noticed allocating insufficient memory
for the terminating null of the string.
--- libdm/libdm-stats.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
libdm/libdm-stats.c +2 -2
@@ -1009,7 +1009,7 @@ static int _stats_parse_list(struct dm_stats *dms, const char *resp)* dm_task_get_message_response() returns a 'const char *' but * since fmemopen also permits "w" it expects a 'char *'. */ -if (!(list_rows =fmemopen ((char *)resp,strlen (resp),"r" ))) +if (!(list_rows =fmemopen ((char *)resp,strlen (resp) +1 ,"r" ))) return_0;/* begin region table */
@@ -1240,7 +1240,7 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,* dm_task_get_message_response() returns a 'const char *' but * since fmemopen also permits "w" it expects a 'char *'. */ - stats_rows =fmemopen ((char *)resp,strlen (resp),"r" ); + stats_rows =fmemopen ((char *)resp,strlen (resp) +1 ,"r" );if (!stats_rows) goto_bad;