summaryrefslogtreecommitdiff
path: root/ext/ftp/ftp.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ftp/ftp.c')
-rw-r--r--ext/ftp/ftp.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
index 96e2a7f299..0180c4f598 100644
--- a/ext/ftp/ftp.c
+++ b/ext/ftp/ftp.c
@@ -538,23 +538,31 @@ ftp_rmdir(ftpbuf_t *ftp, const char *dir)
/* {{{ ftp_chmod
*/
int
-ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename)
+ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename, const int filename_len)
{
- char buffer[1024];
+ char *buffer;
- if (ftp == NULL) {
+ if (ftp == NULL || filename_len <= 0) {
+ return 0;
+ }
+
+ if (!(buffer = emalloc(32 + filename_len + 1))) {
return 0;
}
sprintf(buffer, "CHMOD %o %s", mode, filename);
if (!ftp_putcmd(ftp, "SITE", buffer)) {
+ efree(buffer);
return 0;
}
+ efree(buffer);
+
if (!ftp_getresp(ftp) || ftp->resp != 200) {
return 0;
}
+
return 1;
}
/* }}} */