Mercurial > hg > xemacs-beta
comparison lib-src/gnuserv.c @ 456:e7ef97881643 r21-2-43
Import from CVS: tag r21-2-43
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:41:24 +0200 |
parents | abe6d1db359e |
children | c33ae14dd6d0 |
comparison
equal
deleted
inserted
replaced
455:5b97c1cd6ed0 | 456:e7ef97881643 |
---|---|
27 * | 27 * |
28 * (If gnuserv came bundled with your emacs, the README file is probably | 28 * (If gnuserv came bundled with your emacs, the README file is probably |
29 * ../etc/gnuserv.README relative to the directory containing this file) | 29 * ../etc/gnuserv.README relative to the directory containing this file) |
30 */ | 30 */ |
31 | 31 |
32 #if 0 | |
33 static char rcsid [] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !"; | |
34 #endif | |
35 | |
36 #include "gnuserv.h" | 32 #include "gnuserv.h" |
33 | |
34 char gnuserv_version[] = "gnuserv version" GNUSERV_VERSION; | |
35 | |
37 | 36 |
38 #ifdef USE_LITOUT | 37 #ifdef USE_LITOUT |
39 #ifdef linux | 38 #ifdef linux |
40 #include <bsd/sgtty.h> | 39 #include <bsd/sgtty.h> |
41 #else | 40 #else |
457 struct entry *entry; | 456 struct entry *entry; |
458 | 457 |
459 char auth_protocol[128]; | 458 char auth_protocol[128]; |
460 char buf[1024]; | 459 char buf[1024]; |
461 int auth_data_len; | 460 int auth_data_len; |
461 int auth_data_pos; | |
462 int auth_mismatches; | |
462 | 463 |
463 if (fd > 0) | 464 if (fd > 0) |
464 { | 465 { |
465 /* we are checking permission on a real connection */ | 466 /* we are checking permission on a real connection */ |
466 | 467 |
489 if (timed_read(fd, buf, 10, AUTH_TIMEOUT, 1) <= 0) | 490 if (timed_read(fd, buf, 10, AUTH_TIMEOUT, 1) <= 0) |
490 return FALSE; | 491 return FALSE; |
491 | 492 |
492 auth_data_len = atoi(buf); | 493 auth_data_len = atoi(buf); |
493 | 494 |
495 if (auth_data_len <= 0 || auth_data_len > sizeof(buf)) | |
496 { | |
497 return FALSE; | |
498 } | |
499 | |
494 if (timed_read(fd, buf, auth_data_len, AUTH_TIMEOUT, 0) != auth_data_len) | 500 if (timed_read(fd, buf, auth_data_len, AUTH_TIMEOUT, 0) != auth_data_len) |
495 return FALSE; | 501 return FALSE; |
496 | 502 |
497 #ifdef AUTH_MAGIC_COOKIE | 503 #ifdef AUTH_MAGIC_COOKIE |
498 if (server_xauth && server_xauth->data && | 504 if (server_xauth && server_xauth->data) |
499 !memcmp(buf, server_xauth->data, auth_data_len)) | 505 { |
500 { | 506 /* Do a compare without comprising info about |
507 the size of the cookie */ | |
508 auth_mismatches = | |
509 ( auth_data_len ^ | |
510 server_xauth->data_length ); | |
511 | |
512 for(auth_data_pos=0; auth_data_pos < auth_data_len; ++auth_data_pos) | |
513 auth_mismatches |= | |
514 ( buf[auth_data_pos] ^ | |
515 server_xauth->data[auth_data_pos % server_xauth->data_length]); | |
516 | |
517 if (auth_mismatches == 0) | |
501 return TRUE; | 518 return TRUE; |
502 } | 519 |
520 for(;rand() % 1000;); | |
521 } | |
522 | |
503 #else | 523 #else |
504 printf ("client tried Xauth, but server is not compiled with Xauth\n"); | 524 printf ("client tried Xauth, but server is not compiled with Xauth\n"); |
505 #endif | 525 #endif |
506 | 526 |
507 /* | 527 /* |