From 6a0fba00e4e5f8003680422d3702c64c744ea86f Mon Sep 17 00:00:00 2001 From: Rainer Jung Date: Fri, 20 Mar 2009 17:42:26 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@756683 13f79535-47bb-0310-9956-ffa450edef68 --- modules/metadata/mod_mime_magic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/metadata/mod_mime_magic.c b/modules/metadata/mod_mime_magic.c index cd7b491a6f..b29d5febf9 100644 --- a/modules/metadata/mod_mime_magic.c +++ b/modules/metadata/mod_mime_magic.c @@ -2099,10 +2099,12 @@ static int zmagic(request_rec *r, unsigned char *buf, apr_size_t nbytes) 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; } -- 2.40.0