set_elem: xml: avoid code duplication

This patch removes 3x code duplication in the XML snprintf function.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src: snprintf: fix buffer lengths

Use 'len' instead of 'size' since we need the remaining unused bytes
in the buffer, not its total size.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
set: json: fix returned string length

Similar to (e7c068d rule: json: fix returned string length).

Based on patch from Arturo.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>