Improvements for telnet server

Author: Xiang Xiao <xiaoxiang@xiaomi.com>

    Check POLLHUP and POLLERR in telnet poll loop

      to handle the remote end close correctly

    Send "NVT"(network virtual terminal) as the default if getenv("TERM") return NULL

      telnet should trigger the error handling if inet_pton return zero
      since zero mean the string has format error

    Don't return 1 in _environ_telnet to avoid trigger the compression
    and remove the redundant TELNET_TELOPT_COMPRESS2 check

    Change telnet_error_u to telnet_error_e required by the coding standard

    Ensure telnet object get freed before the abnormal exit
This commit is contained in:
Xiang Xiao 2020-02-04 19:09:22 -03:00 • committed by Alan Carvalho de Assis
parent 43a36996ca
commit bf3e6e2367
5 changed files with 82 additions and 60 deletions

View file

@ -1,5 +1,5 @@
/****************************************************************************
* apps/netutils/telnetc/telnetc.c
* apps/include/netutils/telnetc.h
*
* Leveraged from libtelnet, https://github.com/seanmiddleditch/libtelnet.
* Modified and re-released under the BSD license:
@ -208,7 +208,7 @@ extern "C"
/* Error codes */
enum telnet_error_u
enum telnet_error_e
{
TELNET_EOK = 0, /* No error */
TELNET_EBADVAL, /* Invalid parameter, or API misuse */
@ -284,7 +284,7 @@ union telnet_event_u
const char *func; /* Function the error occured in */
const char *msg; /* Error message string */
int line; /* Line of file error occured on */
enum telnet_error_u errcode; /* Error code */
enum telnet_error_e errcode; /* Error code */
} error;
/* Command event: for IAC */