Improve http filename parsing.

remotes/origin/master
Victor Julien 14 years ago
parent e237841a8e
commit e3935a2af2

@ -1559,15 +1559,17 @@ static int HtpRequestBodyHandlePOST(HtpState *hstate, HtpTxUserData *htud,
filename_len = bstr_len(tx->parsed_uri->path); filename_len = bstr_len(tx->parsed_uri->path);
} }
result = HTPFileOpen(hstate, filename, filename_len, data, data_len, if (filename != NULL) {
hstate->transaction_cnt, STREAM_TOSERVER); result = HTPFileOpen(hstate, filename, filename_len, data, data_len,
if (result == -1) { hstate->transaction_cnt, STREAM_TOSERVER);
goto end; if (result == -1) {
} else if (result == -2) { goto end;
htud->flags |= HTP_DONTSTORE; } else if (result == -2) {
} else { htud->flags |= HTP_DONTSTORE;
htud->flags |= HTP_FILENAME_SET; } else {
htud->flags &= ~HTP_DONTSTORE; htud->flags |= HTP_FILENAME_SET;
htud->flags &= ~HTP_DONTSTORE;
}
} }
} }
else else
@ -1610,15 +1612,17 @@ static int HtpRequestBodyHandlePUT(HtpState *hstate, HtpTxUserData *htud,
filename_len = bstr_len(tx->parsed_uri->path); filename_len = bstr_len(tx->parsed_uri->path);
} }
result = HTPFileOpen(hstate, filename, filename_len, data, data_len, if (filename != NULL) {
hstate->transaction_cnt, STREAM_TOSERVER); result = HTPFileOpen(hstate, filename, filename_len, data, data_len,
if (result == -1) { hstate->transaction_cnt, STREAM_TOSERVER);
goto end; if (result == -1) {
} else if (result == -2) { goto end;
htud->flags |= HTP_DONTSTORE; } else if (result == -2) {
} else { htud->flags |= HTP_DONTSTORE;
htud->flags |= HTP_FILENAME_SET; } else {
htud->flags &= ~HTP_DONTSTORE; htud->flags |= HTP_FILENAME_SET;
htud->flags &= ~HTP_DONTSTORE;
}
} }
} }
else else
@ -1674,16 +1678,18 @@ int HtpResponseBodyHandle(HtpState *hstate, HtpTxUserData *htud,
} }
} }
result = HTPFileOpen(hstate, filename, filename_len, if (filename != NULL) {
result = HTPFileOpen(hstate, filename, filename_len,
data, data_len, hstate->transaction_cnt, STREAM_TOCLIENT); data, data_len, hstate->transaction_cnt, STREAM_TOCLIENT);
SCLogDebug("result %d", result); SCLogDebug("result %d", result);
if (result == -1) { if (result == -1) {
goto end; goto end;
} else if (result == -2) { } else if (result == -2) {
htud->flags |= HTP_DONTSTORE; htud->flags |= HTP_DONTSTORE;
} else { } else {
htud->flags |= HTP_FILENAME_SET; htud->flags |= HTP_FILENAME_SET;
htud->flags &= ~HTP_DONTSTORE; htud->flags &= ~HTP_DONTSTORE;
}
} }
} }
else else

@ -332,7 +332,7 @@ static void FileFree(File *ff) {
} }
void FileContainerAdd(FileContainer *ffc, File *ff) { void FileContainerAdd(FileContainer *ffc, File *ff) {
if (ffc->head == NULL) { if (ffc->head == NULL || ffc->tail == NULL) {
ffc->head = ffc->tail = ff; ffc->head = ffc->tail = ff;
} else { } else {
ffc->tail->next = ff; ffc->tail->next = ff;
@ -358,7 +358,8 @@ int FileStore(File *ff) {
*/ */
int FileSetTx(File *ff, uint16_t txid) { int FileSetTx(File *ff, uint16_t txid) {
SCLogDebug("ff %p txid %"PRIu16, ff, txid); SCLogDebug("ff %p txid %"PRIu16, ff, txid);
ff->txid = txid; if (ff != NULL)
ff->txid = txid;
SCReturnInt(0); SCReturnInt(0);
} }

Loading…
Cancel
Save