1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 10:25:13 +03:00

cov: dm stats missed terminating null

Coverity noticed allocating insufficient memory
for the terminating null of the string.
This commit is contained in:
Zdenek Kabelac 2018-10-15 14:45:16 +02:00
parent 77aa055e8a
commit 20971f7034

View File

@ -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;