httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgau...@hyperreal.org
Subject cvs commit: apache-1.3/src/modules/standard mod_mime_magic.c
Date Wed, 21 Apr 1999 03:42:35 GMT
dgaudet     99/04/20 20:42:35

  Modified:    src      CHANGES
               src/modules/standard mod_mime_magic.c
  Log:
  uncompress and gzip don't like getting only 4k of the file... pass them
  the entire file (but we still only read 4k, so they don't get to run
  for long).
  
  PR:		4097
  Submitted by:	Marcin Cieslak <saper@system.pl>
  
  Revision  Changes    Path
  1.1319    +7 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1318
  retrieving revision 1.1319
  diff -u -r1.1318 -r1.1319
  --- CHANGES	1999/04/21 02:00:48	1.1318
  +++ CHANGES	1999/04/21 03:42:31	1.1319
  @@ -1,5 +1,12 @@
   Changes with Apache 1.3.7
   
  +  *) mod_mime_magic passed only the first 4k of a file to
  +     uncompress/gzip, but those tools sometimes do not produce
  +     any output unless a sufficient portion of the compressed
  +     file is input.  Change to pass the entire file -- but
  +     only read 4k of output.
  +     [Marcin Cieslak <saper@system.pl>] PR#4097
  +
     *) "IndexOptions None" generated extra spaces at the end of each
        line.  [inkling@firstnethou.com] PR#3770
   
  
  
  
  1.39      +27 -21    apache-1.3/src/modules/standard/mod_mime_magic.c
  
  Index: mod_mime_magic.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_mime_magic.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- mod_mime_magic.c	1999/01/01 19:05:11	1.38
  +++ mod_mime_magic.c	1999/04/21 03:42:33	1.39
  @@ -242,7 +242,7 @@
   static int ascmagic(request_rec *, unsigned char *, int);
   static int is_tar(unsigned char *, int);
   static int softmagic(request_rec *, unsigned char *, int);
  -static void tryit(request_rec *, unsigned char *, int);
  +static void tryit(request_rec *, unsigned char *, int, int);
   static int zmagic(request_rec *, unsigned char *, int);
   
   static int getvalue(server_rec *, struct magic *, char **);
  @@ -256,7 +256,7 @@
   static int mcheck(request_rec *, union VALUETYPE *, struct magic *);
   static void mprint(request_rec *, union VALUETYPE *, struct magic *);
   
  -static int uncompress(request_rec *, int, const unsigned char *,
  +static int uncompress(request_rec *, int, 
   		      unsigned char **, int);
   static long from_oct(int, char *);
   static int fsmagic(request_rec *r, const char *fn);
  @@ -887,7 +887,7 @@
   	magic_rsl_puts(r, MIME_TEXT_UNKNOWN);
       else {
   	buf[nbytes++] = '\0';	/* null-terminate it */
  -	tryit(r, buf, nbytes);
  +	tryit(r, buf, nbytes, 1); 
       }
   
       (void) ap_pclosef(r->pool, fd);
  @@ -897,13 +897,15 @@
   }
   
   
  -static void tryit(request_rec *r, unsigned char *buf, int nb)
  +static void tryit(request_rec *r, unsigned char *buf, int nb, int checkzmagic)
   {
       /*
        * Try compression stuff
        */
  -    if (zmagic(r, buf, nb) == 1)
  -	return;
  +	if (checkzmagic == 1) {  
  +			if (zmagic(r, buf, nb) == 1)
  +			return;
  +	}
   
       /*
        * try tests in /etc/magic (or surrogate magic file)
  @@ -2082,9 +2084,13 @@
       char *encoding;	/* MUST be lowercase */
   } compr[] = {
   
  +    /* we use gzip here rather than uncompress because we have to pass
  +     * it a full filename -- and uncompress only considers filenames
  +     * ending with .Z
  +     */
       {
   	"\037\235", 2, {
  -	    "uncompress", "-c", NULL
  +	    "gzip", "-dcq", NULL
   	}, 0, "x-compress"
       },
       {
  @@ -2121,8 +2127,8 @@
       if (i == ncompr)
   	return 0;
   
  -    if ((newsize = uncompress(r, i, buf, &newbuf, nbytes)) > 0) {
  -	tryit(r, newbuf, newsize);
  +    if ((newsize = uncompress(r, i, &newbuf, nbytes)) > 0) {
  +	tryit(r, newbuf, newsize, 0);
   
   	/* set encoding type in the request record */
   	r->content_encoding = compr[i].encoding;
  @@ -2139,6 +2145,13 @@
   static int uncompress_child(void *data, child_info *pinfo)
   {
       struct uncompress_parms *parm = data;
  +	char *new_argv[4];
  +
  +	new_argv[0] = compr[parm->method].argv[0];
  +	new_argv[1] = compr[parm->method].argv[1];
  +	new_argv[2] = parm->r->filename;
  +	new_argv[3] = NULL;
  +
   #if defined(WIN32)
       int child_pid;
   #endif
  @@ -2149,10 +2162,10 @@
   
   #if defined(WIN32)
       child_pid = spawnvp(compr[parm->method].argv[0],
  -			compr[parm->method].argv);
  +			new_argv);
       return (child_pid);
   #else
  -    execvp(compr[parm->method].argv[0], compr[parm->method].argv);
  +    execvp(compr[parm->method].argv[0], new_argv);
       ap_log_rerror(APLOG_MARK, APLOG_ERR, parm->r,
   		MODNAME ": could not execute `%s'.",
   		compr[parm->method].argv[0]);
  @@ -2161,11 +2174,11 @@
   }
   
   
  -static int uncompress(request_rec *r, int method, const unsigned char *old,
  +static int uncompress(request_rec *r, int method, 
   		      unsigned char **newch, int n)
   {
       struct uncompress_parms parm;
  -    BUFF *bin, *bout;
  +    BUFF *bout;
       pool *sub_pool;
   
       parm.r = r;
  @@ -2178,19 +2191,12 @@
       sub_pool = ap_make_sub_pool(r->pool);
   
       if (!ap_bspawn_child(sub_pool, uncompress_child, &parm, kill_always,
  -			 &bin, &bout, NULL)) {
  +			 NULL, &bout, NULL)) {
   	ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
   		    MODNAME ": couldn't spawn uncompress process: %s", r->uri);
   	return -1;
       }
   
  -    if (ap_bwrite(bin, old, n) != n) {
  -	ap_destroy_pool(sub_pool);
  -	ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
  -		    MODNAME ": write failed.");
  -	return -1;
  -    }
  -    ap_bclose(bin);
       *newch = (unsigned char *) ap_palloc(r->pool, n);
       if ((n = ap_bread(bout, *newch, n)) <= 0) {
   	ap_destroy_pool(sub_pool);
  
  
  

Mime
View raw message