service: fix compilation with GCC 10
Building with GCC 10.3.0 fails with the following error:
service.c:243:10: error: 'strncpy' offset 6 from the object at 'b' is
out of the bounds of referenced subobject 'name' with type 'uint8_t[]'
{aka 'unsigned char[]'} at offset 6 [-Werror=array-bounds]
243 | s->id = strncpy(d_id, blobmsg_name(b), n);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix it by passing the length returned by strlen to strncpy without
adding an extra byte for the string terminator. Add the extra byte only
in the calloc_a call, which will initialize it to NULL.
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
Acked-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>