From: Kern Sibbald Date: Sun, 10 Feb 2008 18:24:21 +0000 (+0000) Subject: kes Fix bug #1047, which had a heap overrun when stripping certain paths, X-Git-Tag: Release-7.0.0~5043 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=456a2e1b18d447aa84c29403a4695db137a642ea;p=bacula%2Fbacula kes Fix bug #1047, which had a heap overrun when stripping certain paths, and do not strip paths on symbolic links. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6396 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 2bdeac3f04..0127b181c5 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -523,20 +523,6 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) update_db = save_update_db; jr.PoolId = pr.PoolId; -#ifdef xxx - /* Set start positions into JCR */ - if (dev->is_tape()) { - /* - * Note, we have already advanced past current block, - * so the correct number is block_num - 1 - */ - dcr->StartBlock = dev->block_num - 1; - dcr->StartFile = dev->file; - } else { - dcr->StartBlock = (uint32_t)dev->file_addr; - dcr->StartFile = (uint32_t)(dev->file_addr >> 32); - } -#endif mjcr->start_time = jr.StartTime; mjcr->JobLevel = jr.JobLevel; diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index d2a2243ebb..b5ea0c63ef 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + Copyright (C) 2000-2008 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -463,7 +463,7 @@ public: /* Methods */ bool is_dev_locked() { return m_dev_locked; } void dlock() { dev->dlock(); m_dev_locked = true; } - void dunlock() { dev->dunlock(); m_dev_locked = false;} + void dunlock() { m_dev_locked = false; dev->dunlock(); } void dblock(int why) { dev->dblock(why); } }; diff --git a/bacula/src/stored/device.c b/bacula/src/stored/device.c index 3aeaf86927..b38b512d0b 100644 --- a/bacula/src/stored/device.c +++ b/bacula/src/stored/device.c @@ -200,6 +200,19 @@ bail_out: return ok; /* device locked */ } +void set_start_vol_position(DCR *dcr) +{ + DEVICE *dev = dcr->dev; + /* Set new start position */ + if (dev->is_tape()) { + dcr->StartBlock = dev->block_num; + dcr->StartFile = dev->file; + } else { + dcr->StartBlock = (uint32_t)dev->file_addr; + dcr->StartFile = (uint32_t)(dev->file_addr >> 32); + } +} + /* * We have a new Volume mounted, so reset the Volume parameters * concerning this job. The global changes were made earlier @@ -208,24 +221,11 @@ bail_out: void set_new_volume_parameters(DCR *dcr) { JCR *jcr = dcr->jcr; - DEVICE *dev = dcr->dev; if (dcr->NewVol && !dir_get_volume_info(dcr, GET_VOL_INFO_FOR_WRITE)) { Jmsg1(jcr, M_ERROR, 0, "%s", jcr->errmsg); } - /* Set new start/end positions */ - if (dev->is_tape()) { - dcr->StartBlock = dev->block_num; - dcr->StartFile = dev->file; - } else { - dcr->StartBlock = (uint32_t)dev->file_addr; - dcr->StartFile = (uint32_t)(dev->file_addr >> 32); - } - /* Reset indicies */ - dcr->VolFirstIndex = 0; - dcr->VolLastIndex = 0; + set_new_file_parameters(dcr); jcr->NumWriteVolumes++; - dcr->NewVol = false; - dcr->WroteVol = false; } /* @@ -235,16 +235,8 @@ void set_new_volume_parameters(DCR *dcr) */ void set_new_file_parameters(DCR *dcr) { - DEVICE *dev = dcr->dev; + set_start_vol_position(dcr); - /* Set new start/end positions */ - if (dev->is_tape()) { - dcr->StartBlock = dev->block_num; - dcr->StartFile = dev->file; - } else { - dcr->StartBlock = (uint32_t)dev->file_addr; - dcr->StartFile = (uint32_t)(dev->file_addr >> 32); - } /* Reset indicies */ dcr->VolFirstIndex = 0; dcr->VolLastIndex = 0; diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index d27dd7ea00..115f7ae0d1 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -703,13 +703,7 @@ bool write_session_label(DCR *dcr, int label) Dmsg1(130, "session_label record=%x\n", rec); switch (label) { case SOS_LABEL: - if (dev->is_tape()) { - dcr->StartBlock = dev->block_num; - dcr->StartFile = dev->file; - } else { - dcr->StartBlock = (uint32_t)dev->file_addr; - dcr->StartFile = (uint32_t)(dev->file_addr >> 32); - } + set_start_vol_position(dcr); break; case EOS_LABEL: if (dev->is_tape()) { diff --git a/bacula/src/stored/mac.c b/bacula/src/stored/mac.c index 11528ad84c..59e4c1ff61 100644 --- a/bacula/src/stored/mac.c +++ b/bacula/src/stored/mac.c @@ -1,15 +1,7 @@ -/* - * SD -- mac.c -- responsible for doing - * migration, archive, and copy jobs. - * - * Kern Sibbald, January MMVI - * - * Version $Id$ - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2006-2006 Free Software Foundation Europe e.V. + Copyright (C) 2006-2008 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -33,6 +25,14 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * SD -- mac.c -- responsible for doing + * migration, archive, and copy jobs. + * + * Kern Sibbald, January MMVI + * + * Version $Id$ + */ #include "bacula.h" #include "stored.h" @@ -108,6 +108,7 @@ bool do_mac(JCR *jcr) jcr->dcr->VolFirstIndex = jcr->dcr->VolLastIndex = 0; jcr->run_time = time(NULL); + set_start_vol_position(jcr->dcr); ok = read_records(jcr->read_dcr, record_cb, mount_next_read_volume); goto ok_out; diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index 5ce0294da3..c25b1f8d81 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -127,6 +127,7 @@ void dvd_remove_empty_part(DCR *dcr); bool open_device(DCR *dcr); bool first_open_device(DCR *dcr); bool fixup_device_block_write_error(DCR *dcr); +void set_start_vol_position(DCR *dcr); void set_new_volume_parameters(DCR *dcr); void set_new_file_parameters(DCR *dcr); bool is_device_unmounted(DEVICE *dev);