Make sure all filehandles are closed at the end of a trasaction. See #464 and #465.

Fixes a few typos in some error messages when we are over the limits.
This commit is contained in:
brectanus
2008-03-28 20:00:37 +00:00
parent b74b659114
commit aa6be1614e
4 changed files with 30 additions and 4 deletions

View File

@@ -1100,6 +1100,12 @@ apr_status_t multipart_cleanup(modsec_rec *msr) {
for(i = 0; i < msr->mpd->parts->nelts; i++) {
if (parts[i]->type == MULTIPART_FILE) {
if (parts[i]->tmp_file_name != NULL) {
/* make sure it is closed first */
if (parts[i]->tmp_file_fd > 0) {
close(parts[i]->tmp_file_fd);
parts[i]->tmp_file_fd = -1;
}
if (unlink(parts[i]->tmp_file_name) < 0) {
msr_log(msr, 1, "Multipart: Failed to delete file (part) \"%s\" because %d(%s)",
log_escape(msr->mp, parts[i]->tmp_file_name), errno, strerror(errno));
@@ -1122,6 +1128,12 @@ apr_status_t multipart_cleanup(modsec_rec *msr) {
if ((parts[i]->type == MULTIPART_FILE)&&(parts[i]->tmp_file_size == 0)) {
/* Delete empty file. */
if (parts[i]->tmp_file_name != NULL) {
/* make sure it is closed first */
if (parts[i]->tmp_file_fd > 0) {
close(parts[i]->tmp_file_fd);
parts[i]->tmp_file_fd = -1;
}
if (unlink(parts[i]->tmp_file_name) < 0) {
msr_log(msr, 1, "Multipart: Failed to delete empty file (part) \"%s\" because %d(%s)",
log_escape(msr->mp, parts[i]->tmp_file_name), errno, strerror(errno));
@@ -1138,6 +1150,12 @@ apr_status_t multipart_cleanup(modsec_rec *msr) {
const char *new_filename = NULL;
const char *new_basename = NULL;
/* make sure it is closed first */
if (parts[i]->tmp_file_fd > 0) {
close(parts[i]->tmp_file_fd);
parts[i]->tmp_file_fd = -1;
}
new_basename = file_basename(msr->mp, parts[i]->tmp_file_name);
if (new_basename == NULL) return -1;
new_filename = apr_psprintf(msr->mp, "%s/%s", msr->txcfg->upload_dir,