Hi, (this is about v2)
On Sat, Mar 12, 2022 at 02:58:10PM +0100, Heiko Hund wrote: > As a first step towards DNS configuration in openvpn and a unified way > to push DNS related settings to clients in v2 and v3, this commit adds > support for parsing the new --dns option. Later commits will add support > for setting up DNS on different platforms. > > For now, --dns and DNS related --dhcp-option can be used together for > smoother transition. Settings from --dns will override ones --dhcp-option > where applicable. > > For detailed information about the option consult the documentation in > this commit. [..] > + for (i = 1, d = o->search_domains; d != NULL; i++, d = d->next) > + { > + name_ok = openvpn_snprintf(env_name, sizeof(env_name), > "dns_search_domain_%d", i) && name_ok; > + setenv_str(es, env_name, d->name); > + } With the "&& name_ok" this code does not really improve, even if it was requested in the v1 review... I wonder why we bother to actually *do* this? As in "we already know that this can never overflow here" (because all strings involved are known, and the max width of %d is known, too), but *if* it ever did, calling the subsequent setenv_str() wouldn't be a good idea to do - no? Can we make transform these into a miniwrapper that does - openvpn_snprintf() - check result, warn if overflow - call setenv_str() otherwise like for (i = 1, d = o->search_domains; d != NULL; i++, d = d->next) { _do_dns_env_thing( "dns_search_domain_%d", i, d->name ); } so, shorter lines, clearer code, actual error checking, and no && ugliness :-) (As far as I could see, it's all "setenv_str()" anyway) gert -- "If was one thing all people took for granted, was conviction that if you feed honest figures into a computer, honest figures come out. Never doubted it myself till I met a computer with a sense of humor." Robert A. Heinlein, The Moon is a Harsh Mistress Gert Doering - Munich, Germany g...@greenie.muc.de
signature.asc
Description: PGP signature
_______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel