You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Thomas Hall <tr...@indiana.edu> on 1997/03/27 22:00:02 UTC

general/276: SERVER_PORT variable is negative

	The contract type is `' with a response time of 3 business hours.
	A first analysis should be sent before: Thu Mar 27 16:00:01 PST 1997


>Number:         276
>Category:       general
>Synopsis:       SERVER_PORT variable is negative
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    apache (Apache HTTP Project)
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Thu Mar 27 13:00:01 1997
>Originator:     trhall@indiana.edu
>Organization:
apache
>Release:        1.2b7
>Environment:
Solaris 2.5, gcc.  Can be replicated on Linux 2.0.27, etc.
>Description:
When running a test cgi, I noticed that the SERVER_PORT variable was negative.
The reason for this is that my server is running on port 34803.  This bug
didn't show up under NCSA 1.5.  All I did was upgrade my server from NCSA 1.5 
to Apache 1.2b7.  Redid the new conf files, moved the new httpd into place,
and then tried to run my printenv script.

The problem is that even though the following variables are correct, the 
SERVER_PORT variable is not.

HTTP_HOST:  bobac.cs.indiana.edu:34803
SERVER_NAME:  bobac.cs.indiana.edu

SERVER_PORT:  -30733   ==> This is wrong.  Supposed to be 34803!

I think that you are using a signed short when you should have an unsigned short.

Please let me know if you need more information.

I am running this server in my account on bobac.cs.indiana.edu.  I created my
own test script, printenv, which is the first link below.  The next is the
printenv supplied with the source distribution for Apache 1.2b7.  The last is
the test-cgi script provided with Apache 1.2b7
>How-To-Repeat:
You can try this at:

http://bobac.cs.indiana.edu:34803/cgi-bin/printenv
http://bobac.cs.indiana.edu:34803/cgi-bin/apache-printenv
http://bobac.cs.indiana.edu:34803/cgi-bin/test-cgi
>Fix:
If you look through the source code, you will find that you are declaring
variables that are short instead of unsigned short.  This means that most server
ports work, but after you get to a higher number, it breaks.

For instance, I did not do a make clean on my 1.2b7 src directory, and did the
following:

%grep -i "port" *.h | less

httpd.h:    short host_port;            /* The bound port, for this server */
httpd.h:    short port;                    /* for redirects, etc. */

These should probably be unsigned short host_port and unsigned short port.
I am sure that this needs to be fixed in the code somwhere.  Thanks for
your help.  Please contact me so I will now when this is fixed
>Audit-Trail:
>Unformatted: