Skip to content

Commit

Permalink
autoxflate: verify valid compress.deflate_buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz authored and arogge committed Feb 2, 2023
1 parent 4e47b98 commit bd9eb37
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions core/src/plugins/stored/autoxflate/autoxflate-sd.cc
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2013-2014 Planets Communications B.V.
Copyright (C) 2013-2022 Bareos GmbH & Co. KG
Copyright (C) 2013-2023 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -198,15 +198,13 @@ static bRC newPlugin(PluginContext* ctx)
memset(p_ctx, 0, sizeof(struct plugin_ctx));
ctx->plugin_private_context = (void*)p_ctx; /* set our context pointer */

/*
* Only register plugin events we are interested in.
/* Only register plugin events we are interested in.
*
* bSdEventJobEnd - SD Job finished.
* bSdEventSetupRecordTranslation - Setup the buffers for doing record
* translation. bSdEventReadRecordTranslation - Perform read-side record
* translation. bSdEventWriteRecordTranslation - Perform write-side record
* translation.
*/
* translation. */
bareos_core_functions->registerBareosEvents(
ctx, 4, bSdEventJobEnd, bSdEventSetupRecordTranslation,
bSdEventReadRecordTranslation, bSdEventWriteRecordTranslation);
Expand Down Expand Up @@ -598,9 +596,17 @@ static bool AutoDeflateRecord(PluginContext* ctx, DeviceControlRecord* dcr)
nrec = bareos_core_functions->new_record(/* with_data = */ false);
bareos_core_functions->CopyRecordState(nrec, rec);

if (!dcr->jcr->compress.deflate_buffer) {
Jmsg(ctx, M_FATAL,
_("autoxflate-sd: compress.deflate_buffer was not setup "
"missing bSdEventSetupRecordTranslation call?\n"));
goto bail_out;
}
// Setup the converted DeviceRecord to point with its data buffer to the
// compression buffer.
nrec->data = dcr->jcr->compress.deflate_buffer;


switch (rec->maskedStream) {
case STREAM_FILE_DATA:
case STREAM_WIN32_DATA:
Expand Down

0 comments on commit bd9eb37

Please sign in to comment.