Attention is currently required from: pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/30777 )
Change subject: mslookup: use apn functions from libosmocore ......................................................................
Patch Set 1:
(2 comments)
File src/mslookup/mdns_rfc.c:
https://gerrit.osmocom.org/c/osmo-hlr/+/30777/comment/c55ea0f8_a9087fc5 PS1, Line 80: if (osmo_apn_from_str(buf, buf_len, qst->domain) < 0)
so in here you are assuming that encoding the string into the msg will take always exactly strlen(qs […]
Yes. Each part of the domain is encoded with a label that consists of the size and the string. There's always one more label length than the amount of dots. For example:
"osmocom.org" -> len 11 0x07, 'o', 's', 'm', 'o', 'c', 'o', 'm', 0x03, 'o', 'r', 'g' -> len 12
https://gerrit.osmocom.org/c/osmo-hlr/+/30777/comment/94ad6489_69bf7e46 PS1, Line 105: ret->domain = talloc_size(ret, qname_len - 1);
I'd expect the string to be longer than the buffer due to \0? Is this correct?
qname_len is the size of the encoded domain name + 0x00 at the end, e.g.
0x07, 'o', 's', 'm', 'o', 'c', 'o', 'm', 0x03, 'o', 'r', 'g', 0x00 -> len 13
Therefore "osmocom.org" with 0x00 at the end needs one char less, so it's correct as written there.