mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm-stats: check for empty region and area lists
Check that @stats_list and @stats_print returned data in the _stats_parse_list() and _stats_parse_region() functions before attempting to operate on region and area values. This avoids a coverity warning since fgets() could potentially return no data from the memory buffer returned by the ioctl. In both cases the ioctl would return an error, preventing these functions from running, however it is cleaner to test for the condition explicitly and fail in those cases.
This commit is contained in:
parent
69c2f56005
commit
17ad884836
@ -680,6 +680,10 @@ static int _stats_parse_list(struct dm_stats *dms, const char *resp)
|
||||
nr_regions++;
|
||||
}
|
||||
|
||||
if (!nr_regions)
|
||||
/* no region data read from @stats_list */
|
||||
goto bad;
|
||||
|
||||
dms->nr_regions = nr_regions;
|
||||
dms->max_region = max_region - 1;
|
||||
dms->regions = dm_pool_end_object(mem);
|
||||
@ -936,6 +940,10 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
|
||||
}
|
||||
}
|
||||
|
||||
if (region->start == UINT64_MAX)
|
||||
/* no area data read from @stats_print */
|
||||
goto bad;
|
||||
|
||||
region->len = (start + len) - region->start;
|
||||
region->timescale = timescale;
|
||||
region->counters = dm_pool_end_object(mem);
|
||||
|
Loading…
Reference in New Issue
Block a user