You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rob Hartill <ha...@hyperreal.com> on 1995/12/04 20:46:52 UTC

bug in a contrib module (fwd) [1 of 3]

no ack sent.

Can whoever is responsible send an ack.

this is the first of 3 messages I'm going to forward on this
subject.


Forwarded message:
> From khera@kci.kciLink.com  Mon Dec  4 10:16:42 1995
> Message-Id: <19...@kci.kciLink.com>
> To: Apache Bugs <ap...@mail.apache.org>
> Subject: bug in a contrib module
> Date: Mon, 04 Dec 1995 13:16:16 -0500
> From: Vivek Khera <kh...@kci.kciLink.com>
> 
> There is a bug in the mod_actions.c contributed module, but there is no
> email address to send bug reports.  In the hopes of having it fixed, I'm
> mailing it to the general Apache bug list.  I hope this is not too
> inappropriate.
> 
> Basically, the code does not test for NULL return from table_get(), which
> results in a segfault if you do not define an Action for a given directory.
> This is a very bad error...
> 
> Below is a shar file that contains first a patch against the code in the
> contrib directory, and second, the entire file with the patch applied, in
> case you just want to update the copy in the contrib directory with it.
> 
> Please do update the file, as I'm sure other people will run into this
> difficulty but will not know how to fix it.
> 
> Thanks for your help.
> 
> 								v.
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Vivek Khera, Ph.D.                        Khera Communications, Inc.
> Internet: khera@kciLink.com               Rockville, MD       +1-301-258-8292
> PGP/RIPEM/MIME spoken here                http://www.kciLink.com/home/khera/
> 
> 
> 
> 
> #!/bin/sh
> # This is a shell archive (produced by GNU sharutils 4.1).
> # To extract the files from this archive, save it to some FILE, remove
> # everything before the `!/bin/sh' line above, then type `sh FILE'.
> #
> # Made on 1995-12-04 13:12 EST by <kh...@kci.kciLink.com>.
> # Source directory was `/home/src/kciLink/apache_1.0.0/src'.
> #
> # Existing files will *not* be overwritten unless `-c' is specified.
> #
> # This shar contains:
> # length mode       name
> # ------ ---------- ------------------------------------------
> #   1038 -rw-r--r-- adiff
> #   5384 -r--r--r-- mod_actions.c
> #
> touch -am 1231235999 $$.touch >/dev/null 2>&1
> if test ! -f 1231235999 && test -f $$.touch; then
>   shar_touch=touch
> else
>   shar_touch=:
>   echo
>   echo 'WARNING: not restoring timestamps.  Consider getting and'
>   echo "installing GNU \`touch', distributed in GNU File Utilities..."
>   echo
> fi
> rm -f 1231235999 $$.touch
> #
> # ============= adiff ==============
> if test -f 'adiff' && test X"$1" != X"-c"; then
>   echo 'x - skipping adiff (file already exists)'
> else
>   echo 'x - extracting adiff (text)'
>   sed 's/^X//' << 'SHAR_EOF' > 'adiff' &&
> *** 1.1	1995/12/02 18:56:08
> --- mod_actions.c	1995/12/04 18:09:42
> ***************
> *** 128,135 ****
> X  {
> X      action_dir_config *conf =
> X        (action_dir_config *)get_module_config(r->per_dir_config, &action_module);
> X  
> !     if (!strcmp(table_get(conf->action_types,  r->content_type), NULL))
> X          return(DECLINED);
> X  
> X      if (r->finfo.st_mode == 0) {
> --- 128,136 ----
> X  {
> X      action_dir_config *conf =
> X        (action_dir_config *)get_module_config(r->per_dir_config, &action_module);
> +     char *t = table_get(conf->action_types,  r->content_type);
> X  
> !     if (!t || !strcmp(t, NULL))
> X          return(DECLINED);
> X  
> X      if (r->finfo.st_mode == 0) {
> ***************
> *** 137,144 ****
> X          return NOT_FOUND;
> X      }
> X  
> !     internal_redirect(pstrcat (r->pool, table_get(conf->action_types,  
> !                       r->content_type), r->uri, NULL),r);
> X      return OK;
> X  }
> X  
> --- 138,144 ----
> X          return NOT_FOUND;
> X      }
> X  
> !     internal_redirect(pstrcat (r->pool, t, r->uri, NULL),r);
> X      return OK;
> X  }
> X  
> SHAR_EOF
>   $shar_touch -am 1204131195 'adiff' &&
>   chmod 0644 'adiff' ||
>   echo 'restore of adiff failed'
>   shar_count="`wc -c < 'adiff'`"
>   test 1038 -eq "$shar_count" ||
>     echo "adiff: original size 1038, current size $shar_count"
> fi
> # ============= mod_actions.c ==============
> if test -f 'mod_actions.c' && test X"$1" != X"-c"; then
>   echo 'x - skipping mod_actions.c (file already exists)'
> else
>   echo 'x - extracting mod_actions.c (text)'
>   sed 's/^X//' << 'SHAR_EOF' > 'mod_actions.c' &&
> /*-
> X * Copyright (c) 1995 The Apache Group. All rights reserved.
> X * 
> X *
> X * Apache httpd license
> X * ====================
> X * 
> X *
> X * This is the license for the Apache Server. It covers all the
> X * files which come in this distribution, and should never be removed.
> X * 
> X * The "Apache Group" has based this server, called "Apache", on
> X * public domain code distributed under the name "NCSA httpd 1.3".
> X * 
> X * NCSA httpd 1.3 was placed in the public domain by the National Center 
> X * for Supercomputing Applications at the University of Illinois 
> X * at Urbana-Champaign.
> X * 
> X * As requested by NCSA we acknowledge,
> X * 
> X *  "Portions developed at the National Center for Supercomputing
> X *   Applications at the University of Illinois at Urbana-Champaign."
> X *
> X * Copyright on the sections of code added by the "Apache Group" belong
> X * to the "Apache Group" and/or the original authors. The "Apache Group" and
> X * authors hereby grant permission for their code, along with the
> X * public domain NCSA code, to be distributed under the "Apache" name.
> X * 
> X * Reuse of "Apache Group" code outside of the Apache distribution should
> X * be acknowledged with the following quoted text, to be included with any new
> X * work;
> X * 
> X * "Portions developed by the "Apache Group", taken with permission 
> X *  from the Apache Server   http://www.apache.org/apache/   "
> X *
> X *
> X * Permission is hereby granted to anyone to redistribute Apache under
> X * the "Apache" name. We do not grant permission for the resale of Apache, but
> X * we do grant permission for vendors to bundle Apache free with other software,
> X * or to charge a reasonable price for redistribution, provided it is made
> X * clear that Apache is free. Permission is also granted for vendors to 
> X * sell support for for Apache. We explicitly forbid the redistribution of 
> X * Apache under any other name.
> X * 
> X * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
> X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> X * ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
> X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> X * SUCH DAMAGE.
> X * 
> X */
> X
> X
> X
> /*
> X * mod_action.c: executes scripts based on MIME type
> X *
> X * by Alexei Kosut; based on mod_cgi.c, mod_mime.c and mod_includes.c,
> X * adapted by rst from original NCSA code by Rob McCool
> X *
> X * Usage instructions:
> X *
> X * Action mime/type /cgi-bin/script
> X * 
> X * will activate /cgi-bin/script when a file of content type mime/type. It
> X * sends the URL and file path of the requested document using the standard
> X * CGI PATH_INFO and PATH_TRANSLATED environment variables.
> X *
> X */
> X
> #include "httpd.h"
> #include "http_config.h"
> #include "http_request.h"
> #include "http_core.h"
> #include "http_protocol.h"
> #include "http_main.h"
> #include "http_log.h"
> #include "util_script.h"
> X
> typedef struct {
> X    table *action_types;	/* Added with Action... */
> } action_dir_config;
> X
> module action_module;
> X
> void *create_action_dir_config (pool *p, char *dummy)
> {
> X    action_dir_config *new =
> X      (action_dir_config *) palloc (p, sizeof(action_dir_config));
> X
> X    new->action_types = make_table (p, 4);
> X    
> X    return new;
> }
> X
> void *merge_action_dir_configs (pool *p, void *basev, void *addv)
> {
> X    action_dir_config *base = (action_dir_config *)basev;
> X    action_dir_config *add = (action_dir_config *)addv;
> X    action_dir_config *new =
> X      (action_dir_config *)palloc (p, sizeof(action_dir_config));
> X
> X    new->action_types = overlay_tables (p, add->action_types,
> X					  base->action_types);
> X
> X    return new;
> }
> X
> char *add_action(cmd_parms *cmd, action_dir_config *m, char *type, char *script)
> {
> X    table_set (m->action_types, type, script);
> X    return NULL;
> }
> X
> command_rec action_cmds[] = {
> { "Action", add_action, NULL, OR_FILEINFO, TAKE2, 
> X    "a mime type followed by a script name" },
> { NULL }
> };
> X
> int action_handler (request_rec *r)
> {
> X    action_dir_config *conf =
> X      (action_dir_config *)get_module_config(r->per_dir_config, &action_module);
> X    char *t = table_get(conf->action_types,  r->content_type);
> X
> X    if (!t || !strcmp(t, NULL))
> X        return(DECLINED);
> X
> X    if (r->finfo.st_mode == 0) {
> X        log_reason("File does not exist", r->filename, r);
> X        return NOT_FOUND;
> X    }
> X
> X    internal_redirect(pstrcat (r->pool, t, r->uri, NULL),r);
> X    return OK;
> }
> X
> handler_rec action_handlers[] = {
> { "*/*", action_handler },
> { NULL }
> };
> X
> module action_module = {
> X   STANDARD_MODULE_STUFF,
> X   NULL,			/* initializer */
> X   create_action_dir_config,	/* dir config creater */
> X   merge_action_dir_configs,	/* dir merger --- default is to override */
> X   NULL,			/* server config */
> X   NULL,			/* merge server config */
> X   action_cmds,			/* command table */
> X   action_handlers,		/* handlers */
> X   NULL,			/* filename translation */
> X   NULL,			/* check_user_id */
> X   NULL,			/* check auth */
> X   NULL,			/* check access */
> X   NULL,			/* type_checker */
> X   NULL,			/* fixups */
> X   NULL				/* logger */
> };
> SHAR_EOF
>   $shar_touch -am 1204130995 'mod_actions.c' &&
>   chmod 0444 'mod_actions.c' ||
>   echo 'restore of mod_actions.c failed'
>   shar_count="`wc -c < 'mod_actions.c'`"
>   test 5384 -eq "$shar_count" ||
>     echo "mod_actions.c: original size 5384, current size $shar_count"
> fi
> exit 0
> 


Re: bug in a contrib module (fwd) [1 of 3]

Posted by Alexei Kosut <ak...@nueva.pvt.k12.ca.us>.
On Mon, 4 Dec 1995, Rob Hartill wrote:

> no ack sent.
> 
> Can whoever is responsible send an ack.

I'm responsible for mod_actions, I'll send an ack.

> this is the first of 3 messages I'm going to forward on this
> subject.

The third one was on mod_auth_msql, which isn't mine. Someone else can 
take that.

> > Basically, the code does not test for NULL return from table_get(), which
> > results in a segfault if you do not define an Action for a given directory.
> > This is a very bad error...

He doesn't say what machine/compiler/etc, he is using (I'll ask him in his
email), but it works fine for me. What his code does (the second version)
is to basically replace a !strcmp(..., NULL) with !(...), where ... is a
*char from a table_get. I think I'll end up using his version, beacuse
it's more compact, but is there any reason the former would result in a
seg fault? On my HP-UX 9.04 box, I can run Apache + mod_actions without
any Action directives anywhere, and it works fine... can anyone
confirm/deny this? 

--/ Alexei Kosut <ak...@nueva.pvt.k12.ca.us> /--------/ Lefler on IRC
----------------------------/ <http://www.nueva.pvt.k12.ca.us/~akosut/>
The viewpoints expressed above are entirely false, and in no way
represent Alexei Kosut nor any other person or entity. /--------------