Confusion about KNOT_DNAME_TXT_MAXLEN
KNOT_DNAME_TXT_MAXLEN
is defined as 1005 here:
https://gitlab.nic.cz/knot/knot-dns/blob/master/src/libknot/consts.h#L35-44
...and that math makes sense to me, except for the zero_label
which I assume is the \0
byte that terminates strings in C.
Another way to interpret that is that the maximum string length is 1004 characters + 1 termination byte.
However I see an additional + 1 added here to knot_dname_txt_storage_t
:
https://gitlab.nic.cz/knot/knot-dns/blob/master/src/libknot/dname.h#L41-42
The function knot_dname_to_str()
is called with destination buffer of BOTH LENGTHS throughout the codebase:
1006 bytes: https://gitlab.nic.cz/knot/knot-dns/blob/master/src/knot/common/log.c#L352-353
1005 bytes: https://gitlab.nic.cz/knot/knot-dns/blob/master/src/knot/updates/zone-update.c#L959-960
Is there a reason for using knot_dname_txt_storage_t
sometimes with its + 1 as opposed to just using KNOT_DNAME_TXT_MAXLEN
? Or is this possibly an error?