Dear all, I have claimed before that prototype inclusion is in a miserable state as soon as Kerberos or Shishi is activates. Today I decided to attack a trivial case and immediately I located an serious bug.
Using "--with-shishi" there were warnings about missing prototypes for auth_printsub() and encrypt_printsub() in "telnet/utilities.c" and "telnetd/utility.c". The patch below silences these. My work uncovered the self-contradictory statements for prototype, declaration and definition of encrypt_printsub(), namely in the order of its arguments. The implementation up until now should probably render encrypted content into garbage under some circumstances. Could the original architect step up to claim reproducably whether the recent release produces fully functional TELNET server and client, and whether my proposed changes improve the situation, again reproducably? The patch reverserses the order between auth_printsub() and auth_gen_printsub() in "libtelnet/auth.c" so that proper encapsulation attains. Observe also that every *_printsub() except encrypt_printsub() share the prototype name (unsigned char *, int, unsigned char *, int) Had header inclusion been properly implemented, the present bug would have been easily detected. The iceberg of incomplete coverage in our Kerberos code is still below surface! I maintain the view that verified Kerberos support should be a major milestone for our next release. Best regards, Mats
diff --git a/libtelnet/auth-proto.h b/libtelnet/auth-proto.h index 1735954..f155d36 100644 --- a/libtelnet/auth-proto.h +++ b/libtelnet/auth-proto.h @@ -80,7 +80,7 @@ void auth_reply (unsigned char *, int); void auth_finished (TN_Authenticator *, int); int auth_wait (char *); void auth_disable_name (char *); -void auth_gen_printsub (unsigned char *, int, unsigned char *, int); +void auth_printsub (unsigned char *, int, unsigned char *, int); int auth_sendname (unsigned char *, int); # ifdef KRB4 diff --git a/libtelnet/auth.c b/libtelnet/auth.c index eaa11f0..bec72ad 100644 --- a/libtelnet/auth.c +++ b/libtelnet/auth.c @@ -694,18 +694,7 @@ auth_debug (int mode) auth_debug_mode = mode; } -void -auth_printsub (unsigned char *data, int cnt, unsigned char *buf, int buflen) -{ - TN_Authenticator *ap; - - if ((ap = findauthenticator (data[1], data[2])) && ap->printsub) - (*ap->printsub) (data, cnt, buf, buflen); - else - auth_gen_printsub (data, cnt, buf, buflen); -} - -void +static void auth_gen_printsub (unsigned char *data, int cnt, unsigned char *buf, int buflen) { @@ -727,4 +716,15 @@ auth_gen_printsub (unsigned char *data, int cnt, unsigned char *buf, } *buf = '\0'; } + +void +auth_printsub (unsigned char *data, int cnt, unsigned char *buf, int buflen) +{ + TN_Authenticator *ap; + + if ((ap = findauthenticator (data[1], data[2])) && ap->printsub) + (*ap->printsub) (data, cnt, buf, buflen); + else + auth_gen_printsub (data, cnt, buf, buflen); +} #endif diff --git a/libtelnet/enc-proto.h b/libtelnet/enc-proto.h index e78f7ec..d0c5f1b 100644 --- a/libtelnet/enc-proto.h +++ b/libtelnet/enc-proto.h @@ -86,9 +86,10 @@ void encrypt_send_end (void); void encrypt_wait (void); void encrypt_send_support (void); void encrypt_send_keyid (int, unsigned char *, int, int); +void encrypt_printsub (unsigned char *, int, unsigned char *, int); int net_write (unsigned char *, int); -# ifdef TELENTD +# ifdef TELNETD void encrypt_wait (void); # else int encrypt_cmd (int, char **); diff --git a/libtelnet/encrypt.c b/libtelnet/encrypt.c index 8b349a6..4719043 100644 --- a/libtelnet/encrypt.c +++ b/libtelnet/encrypt.c @@ -967,9 +967,9 @@ encrypt_debug (int mode) encrypt_debug_mode = mode; } -void -encrypt_gen_printsub (unsigned char *data, unsigned char *buf, - int cnt, int buflen) +static void +encrypt_gen_printsub (unsigned char *data, int cnt, + unsigned char *buf, int buflen) { char tbuf[16], *cp; @@ -990,8 +990,8 @@ encrypt_gen_printsub (unsigned char *data, unsigned char *buf, } void -encrypt_printsub (unsigned char *data, unsigned char *buf, - int cnt, int buflen) +encrypt_printsub (unsigned char *data, int cnt, + unsigned char *buf, int buflen) { Encryptions *ep; int type = data[1]; diff --git a/telnet/utilities.c b/telnet/utilities.c index 12a6b08..4da265a 100644 --- a/telnet/utilities.c +++ b/telnet/utilities.c @@ -66,6 +66,13 @@ #include "defines.h" #include "externs.h" +#ifdef AUTHENTICATION +# include <libtelnet/auth.h> +#endif +#ifdef ENCRYPTION +# include <libtelnet/encrypt.h> +#endif + FILE *NetTrace = 0; /* Not in bss, since needs to stay */ int prettydump; diff --git a/telnetd/telnetd.h b/telnetd/telnetd.h index 8a275ec..35ab161 100644 --- a/telnetd/telnetd.h +++ b/telnetd/telnetd.h @@ -51,6 +51,7 @@ #include <arpa/telnet.h> #include <libtelnet/auth.h> +#include <libtelnet/encrypt.h> #include <termios.h>