Project

General

Profile

Actions

Bug #7

closed

Unifed* File Rollover Causes Segmentation Fault

Added by Will Metcalf about 15 years ago. Updated about 15 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Affected Versions:
Effort:
Difficulty:
Label:

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

Actions #1

Updated by Victor Julien about 15 years ago

Please also add a unittest that tests if the filename actually changes on a rotate.

Actions #2

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.

Actions #3

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

Actions #4

Updated by Will Metcalf about 15 years ago

  • File deleted (0001-Small-fix-config-files-not-implemented-yet-here.patch)
Actions #5

Updated by Will Metcalf about 15 years ago

  • File deleted (0002-Alert-Unified-File-Rotation-unittests.patch)
Actions #7

Updated by Will Metcalf about 15 years ago

Additional patch for missing file

Actions #8

Updated by Victor Julien about 15 years ago

  • Status changed from New to Resolved
  • % Done changed from 80 to 100

Please applied, thanks Pablo.

Actions #9

Updated by Victor Julien about 15 years ago

  • Status changed from Resolved to Closed

Apparently "resolved" != "closed" :)

Actions

Also available in: Atom PDF