From: Zdenek Kabelac Date: Mon, 15 Oct 2018 12:45:16 +0000 (+0200) Subject: cov: dm stats missed terminating null X-Git-Tag: v2_03_01~36 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=20971f7034cbd329f873e08869bfb7acf3f1ac0e;p=lvm2.git cov: dm stats missed terminating null Coverity noticed allocating insufficient memory for the terminating null of the string. --- diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c index e9bfa9de9..ea8fdf2ef 100644 --- a/libdm/libdm-stats.c +++ b/libdm/libdm-stats.c @@ -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;