Bug #7
closedUnifed* File Rollover Causes Segmentation Fault
Description
The unified file rollover functions cause a segmentation fault. I believe that the reason is related to the rollover functions in the unified*.c files. They are all setup up similar to this.
int AlertUnifiedLogRotateFile(ThreadVars *t, AlertUnifiedLogThread *aun) {
if (AlertUnifiedLogCloseFile(t,aun) < 0) {
printf("Error: AlertUnifiedLogCloseFile failed\n");
return -1;
}
if (AlertUnifiedLogOpenFileCtx(aun->file_ctx, aun->file_ctx->config_file) < 0) {
printf("Error: AlertUnifiedLogOpenFileCtx, open new log file failed\n");
return -1;
}
if (AlertUnifiedLogWriteFileHeader(t, aun) < 0) {
printf("Error: AlertUnifiedLogAppendFile, write unified header failed\n");
return -1;
}
return 0;
}
But inside of AlertUnifiedLogOpenFileCtx if the value of config_file isn't NULL we don't assign a new value for a file to be opened.
Not sure if this is correct but I could work around the issue by inserting the line aun->file_ctx->config_file = NULL; before the call to AlertUnifiedLogOpenFileCtx()..
int AlertUnifiedLogRotateFile(ThreadVars *t, AlertUnifiedLogThread *aun) {
if (AlertUnifiedLogCloseFile(t,aun) < 0) {
printf("Error: AlertUnifiedLogCloseFile failed\n");
return -1;
}
aun->file_ctx->config_file = NULL; /* XXX delete me when config file is implimented */
if (AlertUnifiedLogOpenFileCtx(aun->file_ctx, aun->file_ctx->config_file) < 0) {
printf("Error: AlertUnifiedLogOpenFileCtx, open new log file failed\n");
return -1;
}
if (AlertUnifiedLogWriteFileHeader(t, aun) < 0) {
printf("Error: AlertUnifiedLogAppendFile, write unified header failed\n");
return -1;
}
return 0;
}
Files
Updated by Victor Julien about 15 years ago
Please also add a unittest that tests if the filename actually changes on a rotate.
Updated by Pablo Rincon about 15 years ago
- % Done changed from 0 to 80
Pending review.
Removed the config_file issue that caused the segmentation fault. Added unittests for log file Rotation in the unified modules.
Updated by Pablo Rincon about 15 years ago
- File 0001-Small-fix-config-files-not-implemented-yet-here.patch added
- File 0002-Alert-Unified-File-Rotation-unittests.patch added
Attaching the patches
Updated by Will Metcalf about 15 years ago
- File deleted (
0001-Small-fix-config-files-not-implemented-yet-here.patch)
Updated by Will Metcalf about 15 years ago
- File deleted (
0002-Alert-Unified-File-Rotation-unittests.patch)
Updated by Pablo Rincon about 15 years ago
- File 0001-Fixing-alert-unified-log-file-rotation.-Adding-unitt.patch 0001-Fixing-alert-unified-log-file-rotation.-Adding-unitt.patch added
Merging the patches here, in one file.
Updated by Will Metcalf about 15 years ago
Additional patch for missing file
Updated by Victor Julien about 15 years ago
- Status changed from New to Resolved
- % Done changed from 80 to 100
Please applied, thanks Pablo.
Updated by Victor Julien about 15 years ago
- Status changed from Resolved to Closed
Apparently "resolved" != "closed" :)