You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Petr Lampa <la...@fee.vutbr.cz> on 1997/02/05 22:20:02 UTC

mod_negotiation/155: Bad handling of lang_index == -1 in is_variant_better().

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


>Number:         155
>Category:       mod_negotiation
>Synopsis:       Bad handling of lang_index == -1 in is_variant_better().
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Wed Feb  5 13:20:01 1997
>Originator:     lampa@fee.vutbr.cz
>Organization:
apache
>Release:        1.2b2, b3, b4, b6
>Environment:
FreeBSD-2.2BETA
>Description:
Problem reported for 1.2b2, still unresolved.

lang_index is initialized to -1, but this value means better quality
then any variant and this is wrong (see test at line 1487 in mod_negotiation.c)!
This situation occurs under this condition:

client header:
Accept-Language:  en, *

httpd.conf:
LanguagePriority  en de

documents:
foo.html.en, and foo.html.de

If exists any document in the language that is not specified in accept headers,
then it has GREATER priority then any other in accept header.
In the example above, foo.html.de is selected.


>How-To-Repeat:
any URL with language content negotiation and wild card
Accept-Language: en, *
>Fix:
*** mod_negotiation.c.old       Mon Jan  6 17:21:50 1997
--- mod_negotiation.c   Mon Jan  6 17:24:57 1997
***************
*** 1482,1490 ****

      /* if language qualities were equal, try the LanguagePriority
       * stuff */
!     if (variant->lang_index > best->lang_index)
          return 0;
!     if (variant->lang_index < best->lang_index) {
          *p_bestq = q;
          return 1;
      }
--- 1482,1491 ----

      /* if language qualities were equal, try the LanguagePriority
       * stuff */
!     if (best->lang_index != -1 && variant->lang_index > best->lang_index)
          return 0;
!     if (varieant->lang_index != -1 &&
!         (variant->lang_index < best->lang_index | best->lang_index == -1)) {
          *p_bestq = q;
          return 1;
      %7
>Audit-Trail:
>Unformatted:



Re: mod_negotiation/155: Bad handling of lang_index == -1 in is_variant_better().

Posted by Dean Gaudet <dg...@arctic.org>.
+1

On Thu, 6 Feb 1997, Paul Sutton wrote:

> On Wed, 5 Feb 1997, Petr Lampa wrote:
> > >Number:         155
> > >Category:       mod_negotiation
> > >Synopsis:       Bad handling of lang_index == -1 in is_variant_better().
> 
> This is also reported in PR#94. The suggested patch (with a couple of
> typos fixed)  fixes the problem. This is already on our to-fix list for
> 1.2b7. +1. 
> 
> //pcs
> 
> *** mod_negotiation.c.cvs	Thu Feb  6 09:13:11 1997
> --- mod_negotiation.c	Thu Feb  6 09:27:47 1997
> ***************
> *** 1482,1490 ****
>       
>       /* if language qualities were equal, try the LanguagePriority
>        * stuff */
> !     if (variant->lang_index > best->lang_index)
>           return 0;
> !     if (variant->lang_index < best->lang_index) {
>           *p_bestq = q;
>           return 1;
>       }
> --- 1482,1491 ----
>       
>       /* if language qualities were equal, try the LanguagePriority
>        * stuff */
> !     if (best->lang_index != -1 && variant->lang_index > best->lang_index)
>           return 0;
> !     if (variant->lang_index != -1 &&
> !         (variant->lang_index < best->lang_index || best->lang_index == -1)) {
>           *p_bestq = q;
>           return 1;
>       }
> 
> 


Re: mod_negotiation/155: Bad handling of lang_index == -1 in is_variant_better().

Posted by Paul Sutton <pa...@ukweb.com>.
On Wed, 5 Feb 1997, Petr Lampa wrote:
> >Number:         155
> >Category:       mod_negotiation
> >Synopsis:       Bad handling of lang_index == -1 in is_variant_better().

This is also reported in PR#94. The suggested patch (with a couple of
typos fixed)  fixes the problem. This is already on our to-fix list for
1.2b7. +1. 

//pcs

*** mod_negotiation.c.cvs	Thu Feb  6 09:13:11 1997
--- mod_negotiation.c	Thu Feb  6 09:27:47 1997
***************
*** 1482,1490 ****
      
      /* if language qualities were equal, try the LanguagePriority
       * stuff */
!     if (variant->lang_index > best->lang_index)
          return 0;
!     if (variant->lang_index < best->lang_index) {
          *p_bestq = q;
          return 1;
      }
--- 1482,1491 ----
      
      /* if language qualities were equal, try the LanguagePriority
       * stuff */
!     if (best->lang_index != -1 && variant->lang_index > best->lang_index)
          return 0;
!     if (variant->lang_index != -1 &&
!         (variant->lang_index < best->lang_index || best->lang_index == -1)) {
          *p_bestq = q;
          return 1;
      }