You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rj...@apache.org on 2009/03/20 18:42:26 UTC

svn commit: r756683 - /httpd/httpd/trunk/modules/metadata/mod_mime_magic.c

Author: rjung
Date: Fri Mar 20 17:42:26 2009
New Revision: 756683

URL: http://svn.apache.org/viewvc?rev=756683&view=rev
Log:
When trying to detect the content type of the
uncompressed content it is often not enough
to read the same number of bytes, we already
read compressed. Since uncompress() allocates a
new buffer, we can increase the number of bytes
to read to the same size, we use in the case,
where the content isn't compressed.

Furthermore zero-terminate the read data to keep
assumptions consistent with the uncompressed case.

Modified:
    httpd/httpd/trunk/modules/metadata/mod_mime_magic.c

Modified: httpd/httpd/trunk/modules/metadata/mod_mime_magic.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/metadata/mod_mime_magic.c?rev=756683&r1=756682&r2=756683&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/metadata/mod_mime_magic.c (original)
+++ httpd/httpd/trunk/modules/metadata/mod_mime_magic.c Fri Mar 20 17:42:26 2009
@@ -2099,10 +2099,12 @@
     if (i == ncompr)
         return 0;
 
-    if ((newsize = uncompress(r, i, &newbuf, nbytes)) > 0) {
+    if ((newsize = uncompress(r, i, &newbuf, HOWMANY)) > 0) {
         /* set encoding type in the request record */
         r->content_encoding = compr[i].encoding;
 
+        newbuf[newsize-1] = '\0';  /* null-terminate uncompressed data */
+        /* Try to detect the content type of the uncompressed data */
         if (tryit(r, newbuf, newsize, 0) != OK) {
             return 0;
         }