Project

General

Profile

Actions

Bug #7

closed
WM PR

Unifed* File Rollover Causes Segmentation Fault

Bug #7: Unifed* File Rollover Causes Segmentation Fault

Added by Will Metcalf over 16 years ago. Updated over 16 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

VJ Updated by Victor Julien over 16 years ago Actions #1

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

PR Updated by Pablo Rincon over 16 years ago Actions #2

  • % 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.

PR Updated by Pablo Rincon over 16 years ago Actions #3

  • File 0001-Small-fix-config-files-not-implemented-yet-here.patch added
  • File 0002-Alert-Unified-File-Rotation-unittests.patch added

Attaching the patches

WM Updated by Will Metcalf over 16 years ago Actions #4

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

WM Updated by Will Metcalf over 16 years ago Actions #5

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

WM Updated by Will Metcalf over 16 years ago Actions #7

Additional patch for missing file

VJ Updated by Victor Julien over 16 years ago Actions #8

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

Please applied, thanks Pablo.

VJ Updated by Victor Julien over 16 years ago Actions #9

  • Status changed from Resolved to Closed

Apparently "resolved" != "closed" :)

Actions

Also available in: PDF Atom