martin      97/10/21 14:37:02

  Modified:    src/main http_core.c
  Log:
  When a <...> section (<Directory> / <Files> / <Location> / ... is not
  closed properly when end-of-file is reached, an error message is returned
  now.
  Reviewed by:  Martin +1, Brian +1, Dean +1
  
  Revision  Changes    Path
  1.127     +31 -2     apachen/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/apachen/src/main/http_core.c,v
  retrieving revision 1.126
  retrieving revision 1.127
  diff -u -r1.126 -r1.127
  --- http_core.c       1997/10/21 21:33:08     1.126
  +++ http_core.c       1997/10/21 21:37:01     1.127
  @@ -310,7 +310,7 @@
            return 1;
        }
       }
  -    /* Either their both special, or their both not special and have the
  +    /* Either they're both special, or they're both not special and have the
        * same number of components.  In any event, we now have to compare
        * the minor key. */
       return a->orig_index - b->orig_index;
  @@ -760,6 +760,24 @@
       return NULL;
   }
   
  +/*
  + * When a section is not closed properly when end-of-file is reached,
  + * then an error message should be printed:
  + */
  +static const char *missing_endsection (pool *p, const char *secname, int 
nest)
  +{
  +    char rply[100];
  +
  +    if (nest < 2)
  +     ap_snprintf(rply, sizeof rply, "Missing </%s> directive at end-of-file",
  +                 secname);
  +    else
  +     ap_snprintf(rply, sizeof rply, "%d missing </%s> directives at 
end-of-file",
  +                 nest, secname);
  +
  +    return pstrdup(p, rply);
  +}
  +
   /* We use this in <DirectoryMatch> and <FilesMatch>, to ensure that 
    * people don't get bitten by wrong-cased regex matches
    */
  @@ -811,6 +829,9 @@
       }
   
       errmsg = srm_command_loop (cmd, new_dir_conf);
  +    if (errmsg == NULL)
  +     return missing_endsection(cmd->pool,
  +                     (cmd->info) ? "DirectoryMatch" : "Directory", 1);
       if (errmsg != end_dir_magic) return errmsg;
   
       conf = (core_dir_config *)get_module_config(new_dir_conf, &core_module);
  @@ -862,6 +883,9 @@
       }
   
       errmsg = srm_command_loop (cmd, new_url_conf);
  +    if (errmsg == NULL)
  +     return missing_endsection(cmd->pool,
  +                     (cmd->info) ? "LocationMatch" : "Location", 1);
       if (errmsg != end_url_magic) return errmsg;
   
       conf = (core_dir_config *)get_module_config(new_url_conf, &core_module);
  @@ -927,6 +951,9 @@
       }
   
       errmsg = srm_command_loop (cmd, new_file_conf);
  +    if (errmsg == NULL)
  +     return missing_endsection(cmd->pool,
  +                     (cmd->info) ? "FilesMatch" : "Files", 1);
       if (errmsg != end_file_magic) return errmsg;
   
       conf = (core_dir_config *)get_module_config(new_file_conf, &core_module);
  @@ -973,7 +1000,7 @@
          nest--;
       }
   
  -    return NULL;
  +    return (nest == 0) ? NULL : missing_endsection(cmd->pool, "IfModule", 
nest);
   }
   
   /* httpd.conf commands... beginning with the <VirtualHost> business */
  @@ -1019,6 +1046,8 @@
       if (s->access_confname)
        process_resource_config (s, s->access_confname, p, ptemp);
       
  +    if (errmsg == NULL)
  +     return missing_endsection(cmd->pool, "Virtualhost", 1);
       if (errmsg == end_virthost_magic) return NULL;
       return errmsg;
   }
  
  
  

Reply via email to