Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins_types/ipv4_address_prefix.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ lyplg_type_print_ipv4_address_prefix(const struct ly_ctx *ctx, const struct lyd_
/* generate canonical value if not already */
if (!value->_canonical) {
/* IPv4 mask + '/' + prefix */
ret = malloc(INET_ADDRSTRLEN + 3);
ret = malloc(INET_ADDRSTRLEN + 4);
LY_CHECK_RET(!ret, NULL);

/* convert back to string */
Expand Down
10 changes: 10 additions & 0 deletions tests/utests/types/inet_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ test_data_xml(void **state)
TEST_SUCCESS_XML("a", "l6", "0.1.58.4/32", STRING, "0.1.58.4/32");
TEST_SUCCESS_XML("a", "l6", "12.1.58.4/8", STRING, "12.0.0.0/8");

/* store-only skips the pattern, so a 3-digit prefix reaches the printer */
{
struct lyd_node *tree;
const char *data = "<l6 xmlns=\"urn:tests:a\">255.255.255.255/255</l6>";

CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_STORE_ONLY, LYD_VALIDATE_PRESENT, LY_SUCCESS, tree);
CHECK_LYD_STRING_PARAM(tree, "<l6 xmlns=\"urn:tests:a\">255.255.255.255/255</l6>\n", LYD_XML, 0);
lyd_free_all(tree);
}

/* ipv6-prefix */
TEST_SUCCESS_XML("a", "l7", "::C:D:E:f:a/112", STRING, "::c:d:e:f:0/112");
TEST_SUCCESS_XML("a", "l7", "::C:D:E:f:a/110", STRING, "::c:d:e:c:0/110");
Expand Down
Loading