[PATCH 4/4] bb_lookup_port(): return 0 if lookup failed

Sergey Ponomarev stokito at gmail.com
Thu Sep 9 22:25:04 UTC 2021


the bb_lookup_port() is a library function and I'm not sure if it's fine to die.
There are already some error messages like:
               o_lport = bb_lookup_port(str_p, o_udpmode ? "udp" : "tcp");
                if (!o_lport)
                        bb_error_msg_and_die("bad local port '%s'", str_p);
Also passing a zero port into xhost2sockaddr() will also make process die

On Thu, 9 Sept 2021 at 23:03, Denys Vlasenko <vda.linux at googlemail.com> wrote:
>
> On Wed, Aug 25, 2021 at 10:15 PM Sergey Ponomarev <stokito at gmail.com> wrote:
> > Unlike xatou16() the bb_lookup_port() won't exit program if port parsing is failed.
> > But it may return a default_port instead. This is not safe because user requested another port.
> > Instead, we return 0 and caller may gracefully show a message or just pass it further.
>
> Let's just print the message and die. None of the callers want to continue
> on such an error.



-- 
Sergey Ponomarev, skype:stokito


More information about the busybox mailing list