Goddamnit it is annoying me so much. It keeps segfaulting whenever i try to use “r->filename” in a post-read-request module. Thats all thats stopping me from getting this modle working correctly =(. Block of code in question:
1: char *fn = r->filename;
2: if (strncmp(conf->pb_dir, fn, sizeof(conf->pb_dir)) != 0) {
3: puts("Didnt accept request.");
4: return DECLINED;
5: }
So
EDIT: Added more code, and a fix.
For those having the same problem, just do a simple check:
1: if (r->filename == NULL) {
2: ap_translate_name(r);
3: if(r->filename == NULL) {
4: //why're we still null?
5: return DECLINED; // decline, otherwise we'll segfault.
6: }
7: }
Apache2 has ap_core_translate or something instead of ap_translate_name. I used this for one module of mine, however, others have said that using this path of action might impair the compatability of other modules, so be warned. This does fix the problem, worked wonders for me. The module is working 100% fine now, except for one bug which actually does not impair the module AT ALL.
Enjoy.
EDIT: The ‘fix’ code above, could probably be formatted into a more efficent ‘while’ loop.