<div dir="ltr">Hello!<br><br>First of all, I want to clarify that I'm new to dnsmasq, so please excuse me if my message seems silly.<br><br>My question is about constructing srv record name in function src/option.c/read_opts, v2.91. Specifically, this part:<br><br>  if (daemon->domain_suffix)<br>    {<br>       /* add domain for any srv record without one. */<br>      struct mx_srv_record *srv;<br>     <br>      for (srv = daemon->mxnames; srv; srv = srv->next)<br>    if (srv->issrv &&<br>      strchr(srv->name, '.') &&<br>      strchr(srv->name, '.') == strrchr(srv->name, '.'))<br>     {<br>      strcpy(buff, srv->name);<br>      strcat(buff, ".");<br>      strcat(buff, daemon->domain_suffix);<br>      free(srv->name);<br>      srv->name = opt_string_alloc(buff);<br>     }<br>    }<br><br>Here, `buff` is a buffer of length ((MAXDNAME * 2) + 1) bytes. If I understand it correctly, after lines:<br><br>   strcpy(buff, srv->name);<br>   strcat(buff, ".");<br><br>maximum len of `buff` will be (MAXDNAME + 1) bytes. My concern is about next line:<br><br>   strcat(buff, daemon->domain_suffix);<br><br>As I see it, there is a possible scenario, where domain name in `resolv.conf` contains non-ASCII symbols. If IDN library is present, this name will be encoded and set as `daemon->domain_suffix` value. I noticed that in function src/util.c/canonicalise, there is a call to `check_name`, which checks len of given non-encoded input string. If it exceeds `MAXDNAME`, NULL will be returned, so `daemon->domain_suffix` will be NULL.<br><br>But what if encoded string exceeds `MAXDNAME`? I haven't found any check for that. If this happens, it could cause overflow in the line<br><br>   strcat(buff, daemon->domain_suffix);<br><br>because `buff` may already contain (`MAXDNAME` + 1) bytes, leaving only `MAXDNAME` bytes free. Do you think it will be useful to add a check of encoded domain name length to prevent such an overflow? Any response would be appreciated.<br><br>I'm aware that such long domain names are unusual and described scenario is unlikely in real life, but I still wanted to highlight it.<br><br>Thank you in advance for your time and expertise!</div>