From nobody@hyperreal.com Thu Mar 27 12:53:38 1997 Received: by taz.hyperreal.com (8.8.4/V2.0) id MAA27735; Thu, 27 Mar 1997 12:53:38 -0800 (PST) Message-Id: <199703272053.MAA27735@taz.hyperreal.com> Date: Thu, 27 Mar 1997 12:53:38 -0800 (PST) From: Thomas Hall Reply-To: trhall@indiana.edu To: apbugs@hyperreal.com Subject: SERVER_PORT variable is negative X-Send-Pr-Version: 3.2 >Number: 276 >Category: general >Synopsis: SERVER_PORT variable is negative >Confidential: no >Severity: critical >Priority: medium >Responsible: apache >State: closed >Class: sw-bug >Submitter-Id: apache >Arrival-Date: Thu Mar 27 13:00:01 1997 >Last-Modified: Sat Mar 29 05:32:34 PST 1997 >Originator: trhall@indiana.edu >Organization: >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: State-Changed-From-To: open-analyzed State-Changed-By: coar@decus.org State-Changed-When: Thu Mar 27 13:27:46 PST 1997 State-Changed-Why: A patch to correct this has been developed and is being tested. State-Changed-From-To: analyzed-closed State-Changed-By: coar@decus.org State-Changed-When: Sat Mar 29 05:32:34 PST 1997 State-Changed-Why: This has been fixed, and the correction will be available in the next release after 1.2b7. That you very much for reporting this, and for using Apache! >Unformatted: