]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
could: Fix 10788 cloud volume deletion crash
authorAlain Spineux <alain@baculasystems.com>
Fri, 15 Mar 2024 15:27:26 +0000 (16:27 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 21 Mar 2024 16:23:16 +0000 (17:23 +0100)
- the problem is about iterating up to including parts.last_index()
  using parts.get(parts.last_index()) is a mistake !!!
  it works most of the time because most of the time this value is NULL
  and the code does a continue
  BUT when parts.last_index() == parts.max_size(), then
  parts.get(parts.last_index()) is out of the allocated memory and can
  contain garbage
- why is the code doing a "continue" ? Is it expected to have a NULL ?
  in the list ?
  in clean_cloud_volume_read_cb() that fill the list, there is no raison
  to have NULL ?
  With the bug, testing for NULL will save us 99% of the time
  Without the bug we can reach 100% :-)

bacula/src/stored/generic_driver.c

index 877dc02d866ce31bda8f8497ae8aa7f84664fe64..e484a6305762694826a61acdca91504038010074 100644 (file)
@@ -1126,10 +1126,7 @@ bool generic_driver::clean_cloud_volume(const char *VolumeName, cleanup_cb_type
 
    int rtn=0;
    int i;
-   for (i=0; (i <= (int)parts.last_index()); i++) {
-      if (!parts.get(i)) {
-         continue;
-      }
+   for (i=0; i < parts.last_index(); i++) {
       int r = call_fct("delete", VolumeName, (char*)parts.get(i), NULL, NULL, cancel_cb, err);
       if (r == 0) {
          Dmsg2(dbglvl, "clean_cloud_volume for %s: Unlink file %s.\n", VolumeName, (char*)parts.get(i));