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

device_mapper: fix incorrect dm_strncpy usage

Patch 668c9d0762 introduced regression,
since the code here would actually always return failing result.
Replace it with more simple call to strndup().
This commit is contained in:
Zdenek Kabelac 2018-12-01 00:41:24 +01:00
parent 6a4a6a7cd7
commit c61c4271a4

View File

@ -203,16 +203,11 @@ bool dm_vdo_status_parse(struct dm_pool *mem, const char *input,
goto bad;
}
if (!(s->device = (!mem) ? malloc((e - b) + 1) : dm_pool_alloc(mem, (e - b) + 1))) {
if (!(s->device = (!mem) ? strndup(b, (te - b)) : dm_pool_alloc(mem, (te - b)))) {
_set_error(result, "out of memory");
goto bad;
}
if (!dm_strncpy(s->device, b, te - b + 1)) {
_set_error(result, "copy device");
goto bad;
}
b = _eat_space(te, e);
#define XX(p, f, fn) if (!_parse_field(&b, e, p, f, fn, result)) goto bad;