mirror of
https://github.com/troglobit/finit.git
synced 2026-11-02 13:20:32 +00:00
inetd.c: Improve error detection in inet port conversion.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
0fd9aa6497
commit
d6490df9a3
1 file changed
+3
-2
@@ -219,15 +219,16 @@ static int getent(char *service, char *proto, struct servent **sv, struct protoe
|
|||||||
{
|
{
|
||||||
*sv = getservbyname(service, proto);
|
*sv = getservbyname(service, proto);
|
||||||
if (!*sv) {
|
if (!*sv) {
|
||||||
|
const char *errstr;
|
||||||
static struct servent s;
|
static struct servent s;
|
||||||
|
|
||||||
s.s_name = service;
|
s.s_name = service;
|
||||||
s.s_port = atonum(service);
|
s.s_port = strtonum(service, 1, UINT16_MAX, &errstr);
|
||||||
s.s_proto = NULL;
|
s.s_proto = NULL;
|
||||||
if (!strcmp("tcp", proto) || !strcmp("udp", proto))
|
if (!strcmp("tcp", proto) || !strcmp("udp", proto))
|
||||||
s.s_proto = proto;
|
s.s_proto = proto;
|
||||||
|
|
||||||
if (s.s_port == -1 || !s.s_proto) {
|
if (errstr || !s.s_proto) {
|
||||||
_e("Invalid/unknown inetd service, cannot create custom entry.");
|
_e("Invalid/unknown inetd service, cannot create custom entry.");
|
||||||
return errno = EINVAL;
|
return errno = EINVAL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user