Squid-2.2.DEVEL3: Assertion failure on FTP PUT to directories Squid died with an assertion failure on FTP PUT requests to directories without a filename. This patch changes it to use STOU, or simply MKD if there is no object to store. Index: squid/src/ftp.c diff -u squid/src/ftp.c:1.1.1.30 squid/src/ftp.c:1.1.1.30.2.1 --- squid/src/ftp.c:1.1.1.30 Sun Feb 14 23:29:59 1999 +++ squid/src/ftp.c Sat Feb 27 19:10:17 1999 @@ -1860,7 +1860,6 @@ static void ftpRestOrList(FtpStateData * ftpState) { - debug(9, 3) ("This is ftpRestOrList\n"); if (ftpState->flags.put) { debug(9, 3) ("ftpRestOrList: Sending STOR request...\n"); @@ -1881,10 +1880,20 @@ static void ftpSendStor(FtpStateData * ftpState) { - assert(ftpState->filepath != NULL); - snprintf(cbuf, 1024, "STOR %s\r\n", ftpState->filepath); - ftpWriteCommand(cbuf, ftpState); - ftpState->state = SENT_STOR; + if (ftpState->filepath != NULL) { + /* Plain file upload */ + snprintf(cbuf, 1024, "STOR %s\r\n", ftpState->filepath); + ftpWriteCommand(cbuf, ftpState); + ftpState->state = SENT_STOR; + } else if (httpHeaderGetInt(&ftpState->request->header, HDR_CONTENT_LENGTH) > 0) { + /* File upload without a filename. use STOU to generate one */ + snprintf(cbuf, 1024, "STOU\r\n"); + ftpWriteCommand(cbuf, ftpState); + ftpState->state = SENT_STOR; + } else { + /* No file to transfer. Only create directories if needed */ + ftpSendReply(ftpState); + } } static void @@ -2297,6 +2306,9 @@ if (code == 226) { err_code = (ftpState->mdtm > 0) ? ERR_FTP_PUT_MODIFIED : ERR_FTP_PUT_CREATED; http_code = (ftpState->mdtm > 0) ? HTTP_ACCEPTED : HTTP_CREATED; + } else if (code == 227) { + err_code = ERR_FTP_PUT_CREATED; + http_code = HTTP_CREATED; } else { err_code = ERR_FTP_PUT_ERROR; http_code = HTTP_INTERNAL_SERVER_ERROR;