[Mod_ftpd] Changes to use 'mod_ftpd' with Win32

Marlon van den Berg marlon.vandenberg at molding.fico.nl
Tue Oct 25 06:56:56 EST 2005


Dear All,

Attached you find a modified 'ftp_protocols.c' file and a diff report file
of the changes.
With these changes *mod_ftpd* does fully run under WinNT4 and WinXP.

Changes:
=======

********************************************

Added at line 37:
----------------
#ifdef WIN32
#undef  APR_FILEPATH_NOTRELATIVE
#define APR_FILEPATH_NOTRELATIVE 0x00
#endif

Reason:
------
Define APR_FILEPATH_NOTRELATIVE will result in empty URI's by APR function
'apr_filepath_merge'. This caused a lot of FTP commands to fail (like STOR,
DELETE, RENAME...).

********************************************

Replaced lines 178 - 179:
------------------------
	ftpd_svr_config_rec *pConfig = ap_get_module_config(((request_rec
*)r)->server->module_config,
					&ftpd_module);
With:
----
	ftpd_svr_config_rec *pConfig = (ftpd_svr_config_rec*)r;

Replaced line 535:
-----------------
	apr_pool_cleanup_register(ur->p, (void *)r, ftpd_limit_checkout,
apr_pool_cleanup_null);
With:
----
	apr_pool_cleanup_register(ur->p, (void*)pConfig,
ftpd_limit_checkout, apr_pool_cleanup_null);

Reason:
------
Parts of the request record aren't valid anymore when function
'ftpd_limit_checkout' was called after an FTP QUIT command. Only the
configuration record is required in that function, therefor only the address
of that record is passed (is also still valid at that point).
Accessing the request record did cause a runtime error after a QUIT command.

********************************************

Replaced line 278:
-----------------
	char temp[FTPD_IO_BUFFER_MAX*2];
With:
----
	char *temp = (char*)malloc(FTPD_IO_BUFFER_MAX*2);

Added at line 300:
-----------------
	free(temp);

Reason:
------
The *temp* array claimed too much stack space and caused a runtime error
when handling ASCii files.
(I don't know if *malloc* and *free* are allowed in Apache modules. If
someone has a better solution, please tell me. I'm never too old to learn :)

********************************************

Replaced line 1078:
------------------
	char buff[FTPD_IO_BUFFER_MAX];
With:
----
	char *buff = apr_palloc(r->pool, FTPD_IO_BUFFER_MAX);

Reason:
------
The *buff* array claimed too much stack space. This caused a runtime error
when downloading from server.

********************************************

Replaced line 1266:
------------------
    char buff[FTPD_IO_BUFFER_MAX];
With:
----
    char *buff = apr_palloc(r->pool, FTPD_IO_BUFFER_MAX);

Reason:
------
The *buff* array claimed too much stack space. This caused a runtime error
when uploading to server.

********************************************

I also tested the last two changes with usage of *malloc* and *free* instead
of using *apr_palloc*. It looked to me as if both download and upload were
faster. The only disadvantage is that the *free* has to be placed before
every *return* statement within the function.

Best regards,
Marlon

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ftp_protocol.rar
Type: application/octet-stream
Size: 11381 bytes
Desc: not available
Url : http://lists.outoforder.cc/pipermail/mod_ftpd/attachments/20051025/f6bd3a6d/ftp_protocol.obj


More information about the Mod_ftpd mailing list