Le 11/06/2013 09:41, jaillet...@apache.org a écrit :
Author: jailletc36
Date: Tue Jun 11 07:41:40 2013
New Revision: 1491700
URL:http://svn.apache.org/r1491700
Log:
According to comment in 'magic_rsl_add' and to the way 'magic_rsl_printf'
manages its buffer, I think that this memory should be apr_pstrdup'ed.
This has been like that forever, but seems broken to me.
Untested.
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=1491700&r1=1491699&r2=1491700&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/metadata/mod_mime_magic.c (original)
+++ httpd/httpd/trunk/modules/metadata/mod_mime_magic.c Tue Jun 11 07:41:40 2013
@@ -606,7 +606,7 @@ static int magic_rsl_putchar(request_rec
/* high overhead for 1 char - just hope they don't do this much */
str[0] = c;
str[1] = '\0';
- return magic_rsl_add(r, str);
+ return magic_rsl_add(r, apr_pstrdup(r->pool, str));
}
/* allocate and copy a contiguous string from a result string list */
I made some testing with mod_mime_magic.
The change above has a real impact on output generated by the module.
I modified the magic file in order to see if I could reproduced PR21253
<https://issues.apache.org/bugzilla/show_bug.cgi?id=21253>
My magic file has :
>>>>>>>>>>>>>>>>>>>>>>>>>
# XML eXtensible Markup Language, from Linus Walleij <tr...@df.lth.se>
0 string \<?xml
>6 string \<!DOCTYPE\ HTML application/xhtml+xml
>7 string !DOCTYPE\ HTML application2/xhtml+xml2
>8 string DOCTYPE\ HTML application3/xhtml+xml3
>9 string OCTYPE\ HTML application4/xhtml+xml4
>>>>>>>>>>>>>>>>>>>>>>>>>
Module unmodified gives :
$ wget -S --no-cache http://localhost/test.xx
--2013-06-12 20:44:11-- http://localhost/test.xx
Résolution de localhost (localhost)... 127.0.0.1
Connexion vers localhost (localhost)|127.0.0.1|:80... connecté.
requête HTTP transmise, en attente de la réponse...
HTTP/1.1 200 OK
Date: Wed, 12 Jun 2013 18:44:11 GMT
Server: Apache/2.5.0-dev (Unix)
Last-Modified: Wed, 12 Jun 2013 09:43:16 GMT
ETag: "24a-4def1d7da1d1d"
Accept-Ranges: bytes
Content-Length: 586
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type:
application/xhtml+xml\aapplication2/xhtml+xml2\aapplication3/xhtml+xml3\aapplication4/xhtml+xml4
<------------------------
Taille : 586
[application/xhtml+xml\aapplication2/xhtml+xml2\aapplication3/xhtml+xml3\aapplication4/xhtml+xml4]
Enregistre : «test.xx.30»
Module modified with the strdup gives :
$ wget -S --no-cache http://localhost/test.xx
--2013-06-12 20:44:54-- http://localhost/test.xx
Résolution de localhost (localhost)... 127.0.0.1
Connexion vers localhost (localhost)|127.0.0.1|:80... connecté.
requête HTTP transmise, en attente de la réponse...
HTTP/1.1 200 OK
Date: Wed, 12 Jun 2013 18:44:54 GMT
Server: Apache/2.5.0-dev (Unix)
Last-Modified: Wed, 12 Jun 2013 09:43:16 GMT
ETag: "24a-4def1d7da1d1d"
Accept-Ranges: bytes
Content-Length: 586
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/xhtml+xml <------------------------
Content-Encoding: application2/xhtml+xml2 <------------------------
Taille : 586 [application/xhtml+xml]
Enregistre : «test.xx.31»
Before digging deeper in the module, I was wondering if someone was
familiar with it and could give me some pointer about its internal.
Best regards,
CJ