X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lib-src%2Fgnuserv.c;h=2ba5785f666388b9eb82b9a16f266ada21b42e57;hb=83d336217a47cd6b816a3c843f439c329f1afb21;hp=419baa8c2780f1b6b7ee021a095363846059cda7;hpb=d8bd7eee3147c839d3c74d1823c139cd54867a75;p=chise%2Fxemacs-chise.git diff --git a/lib-src/gnuserv.c b/lib-src/gnuserv.c index 419baa8..2ba5785 100644 --- a/lib-src/gnuserv.c +++ b/lib-src/gnuserv.c @@ -29,12 +29,11 @@ * ../etc/gnuserv.README relative to the directory containing this file) */ -#if 0 -static char rcsid [] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !"; -#endif - #include "gnuserv.h" +char gnuserv_version[] = "gnuserv version" GNUSERV_VERSION; + + #ifdef USE_LITOUT #ifdef linux #include @@ -379,7 +378,7 @@ handle_response (void) #ifdef INTERNET_DOMAIN_SOCKETS struct entry { - u_long host_addr; + unsigned long host_addr; struct entry *next; }; @@ -451,7 +450,7 @@ timed_read (int fd, char *buf, int max, int timeout, int one_line) permitted -- return whether a given host is allowed to connect to the server. */ static int -permitted (u_long host_addr, int fd) +permitted (unsigned long host_addr, int fd) { int key; struct entry *entry; @@ -459,6 +458,8 @@ permitted (u_long host_addr, int fd) char auth_protocol[128]; char buf[1024]; int auth_data_len; + int auth_data_pos; + int auth_mismatches; if (fd > 0) { @@ -491,15 +492,34 @@ permitted (u_long host_addr, int fd) auth_data_len = atoi(buf); + if (auth_data_len <= 0 || auth_data_len > sizeof(buf)) + { + return FALSE; + } + if (timed_read(fd, buf, auth_data_len, AUTH_TIMEOUT, 0) != auth_data_len) return FALSE; #ifdef AUTH_MAGIC_COOKIE - if (server_xauth && server_xauth->data && - !memcmp(buf, server_xauth->data, auth_data_len)) - { + if (server_xauth && server_xauth->data) + { + /* Do a compare without comprising info about + the size of the cookie */ + auth_mismatches = + ( auth_data_len ^ + server_xauth->data_length ); + + for(auth_data_pos=0; auth_data_pos < auth_data_len; ++auth_data_pos) + auth_mismatches |= + ( buf[auth_data_pos] ^ + server_xauth->data[auth_data_pos % server_xauth->data_length]); + + if (auth_mismatches == 0) return TRUE; - } + + for(;rand() % 1000;); + } + #else printf ("client tried Xauth, but server is not compiled with Xauth\n"); #endif @@ -540,7 +560,7 @@ permitted (u_long host_addr, int fd) already there. */ static void -add_host (u_long host_addr) +add_host (unsigned long host_addr) { int key; struct entry *new_entry; @@ -576,7 +596,7 @@ setup_table (void) FILE *host_file; char *file_name; char hostname[HOSTNAMSZ]; - u_int host_addr; + unsigned int host_addr; int i, hosts=0; /* Make sure every entry is null */