comparison lib-src/gnuserv.c @ 647:b39c14581166

[xemacs-hg @ 2001-08-13 04:45:47 by ben] removal of unsigned, size_t, etc.
author ben
date Mon, 13 Aug 2001 04:46:48 +0000
parents 023b83f4e54b
children 943eaba38521
comparison
equal deleted inserted replaced
646:00c54252fe4f 647:b39c14581166
483 483
484 /* 484 /*
485 * doing magic cookie auth 485 * doing magic cookie auth
486 */ 486 */
487 487
488 if (timed_read(fd, buf, 10, AUTH_TIMEOUT, 1) <= 0) 488 if (timed_read (fd, buf, 10, AUTH_TIMEOUT, 1) <= 0)
489 return FALSE; 489 return FALSE;
490 490
491 auth_data_len = atoi(buf); 491 auth_data_len = atoi (buf);
492 492
493 if (auth_data_len <= 0 || auth_data_len > sizeof(buf)) 493 if (auth_data_len <= 0 || auth_data_len > (int) sizeof (buf))
494 { 494 {
495 return FALSE; 495 return FALSE;
496 } 496 }
497 497
498 if (timed_read(fd, buf, auth_data_len, AUTH_TIMEOUT, 0) != auth_data_len) 498 if (timed_read (fd, buf, auth_data_len, AUTH_TIMEOUT, 0) !=
499 auth_data_len)
499 return FALSE; 500 return FALSE;
500 501
501 #ifdef AUTH_MAGIC_COOKIE 502 #ifdef AUTH_MAGIC_COOKIE
502 if (server_xauth && server_xauth->data) 503 if (server_xauth && server_xauth->data)
503 { 504 {
506 int auth_data_pos; 507 int auth_data_pos;
507 int auth_mismatches = 508 int auth_mismatches =
508 ( auth_data_len ^ 509 ( auth_data_len ^
509 server_xauth->data_length ); 510 server_xauth->data_length );
510 511
511 for(auth_data_pos=0; auth_data_pos < auth_data_len; ++auth_data_pos) 512 for(auth_data_pos = 0; auth_data_pos < auth_data_len;
513 ++auth_data_pos)
512 auth_mismatches |= 514 auth_mismatches |=
513 ( buf[auth_data_pos] ^ 515 ( buf[auth_data_pos] ^
514 server_xauth->data[auth_data_pos % server_xauth->data_length]); 516 server_xauth->data[auth_data_pos %
517 server_xauth->data_length]);
515 518
516 if (auth_mismatches == 0) 519 if (auth_mismatches == 0)
517 return TRUE; 520 return TRUE;
518 521
519 for(;rand() % 1000;); 522 for(;rand() % 1000;);
602 for (i=0; i<TABLE_SIZE; i++) 605 for (i=0; i<TABLE_SIZE; i++)
603 permitted_hosts[i] = NULL; 606 permitted_hosts[i] = NULL;
604 607
605 gethostname(hostname,HOSTNAMSZ); 608 gethostname(hostname,HOSTNAMSZ);
606 609
607 if ((host_addr = internet_addr(hostname)) == -1) 610 if ((host_addr = internet_addr (hostname)) == (unsigned int) -1)
608 { 611 {
609 fprintf(stderr,"%s: unable to find %s in /etc/hosts or from YP", 612 fprintf(stderr,"%s: unable to find %s in /etc/hosts or from YP",
610 progname,hostname); 613 progname,hostname);
611 exit(1); 614 exit(1);
612 } /* if */ 615 } /* if */
628 631
629 if (((file_name = getenv("GNU_SECURE")) != NULL && /* security file */ 632 if (((file_name = getenv("GNU_SECURE")) != NULL && /* security file */
630 (host_file = fopen(file_name,"r")) != NULL)) /* opened ok */ 633 (host_file = fopen(file_name,"r")) != NULL)) /* opened ok */
631 { 634 {
632 while ((fscanf(host_file,"%s",hostname) != EOF)) /* find a host */ 635 while ((fscanf(host_file,"%s",hostname) != EOF)) /* find a host */
633 if ((host_addr = internet_addr(hostname)) != -1)/* get its addr */ 636 if ((host_addr = internet_addr(hostname)) != (unsigned int) -1)
637 /* get its addr */
634 { 638 {
635 add_host(host_addr); /* add the addr */ 639 add_host(host_addr); /* add the addr */
636 hosts++; 640 hosts++;
637 } 641 }
638 fclose(host_file); 642 fclose(host_file);
639 } /* if */ 643 } /* if */
640 644