You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Roy T. Fielding" <fi...@kiwi.ICS.UCI.EDU> on 1997/03/07 13:33:09 UTC

Re: [PATCH] deal with long hostnames -- Re: [BUG]: "httpd server exits if no fqdn name found and ServerName not hardwired" on Solaris 2.x (fwd)

+1 if you change 

    str[ MAXHOSTNAMELEN ] = 0;
to
    str[MAXHOSTNAMELEN] = '\0';

And what's with the weird coding style?  It would make my life easier
if everyone stuck to the style guidelines.

.....Roy

Re: [PATCH] deal with long hostnames -- Re: [BUG]: "httpd server exits if no fqdn name found and ServerName not hardwired" on Solaris 2.x (fwd)

Posted by Dean Gaudet <dg...@arctic.org>.
On Fri, 7 Mar 1997, Roy T. Fielding wrote:
> +1 if you change 
> 
>     str[ MAXHOSTNAMELEN ] = 0;
> to
>     str[MAXHOSTNAMELEN] = '\0';
> 
> And what's with the weird coding style?  It would make my life easier
> if everyone stuck to the style guidelines.

What style guidelines?  Are they posted somewhere?  I avoided that
entire thread 'cause it was so busy... Were you referring to my new code,
or the existing code?

Anyhow, here's the patch with your tweak.

Dean

Index: util.c
===================================================================
RCS file: /export/home/cvs/apache/src/util.c,v
retrieving revision 1.46
diff -c -3 -r1.46 util.c
*** util.c	1997/03/02 18:15:12	1.46
--- util.c	1997/03/06 08:02:22
***************
*** 1186,1197 ****
  
  char *get_local_host(pool *a)
  {
!     char str[128];
!     int len = 128;
      char *server_hostname;
- 
      struct hostent *p;
!     gethostname(str, len);
      if((!(p=gethostbyname(str))) || (!(server_hostname = find_fqdn(a, p)))) {
          fprintf(stderr,"httpd: cannot determine local host name.\n");
  	fprintf(stderr,"Use ServerName to set it manually.\n");
--- 1192,1209 ----
  
  char *get_local_host(pool *a)
  {
! #ifndef MAXHOSTNAMELEN
! #define MAXHOSTNAMELEN 256
! #endif
!     char str[MAXHOSTNAMELEN+1];
      char *server_hostname;
      struct hostent *p;
! 
!     if( gethostname( str, sizeof( str ) - 1 ) != 0 ) {
! 	perror( "Unable to gethostname" );
! 	exit(1);
!     }
!     str[MAXHOSTNAMELEN] = '\0';
      if((!(p=gethostbyname(str))) || (!(server_hostname = find_fqdn(a, p)))) {
          fprintf(stderr,"httpd: cannot determine local host name.\n");
  	fprintf(stderr,"Use ServerName to set it manually.\n");