gparted/include
Mike Fleetwood 4cc426c6cf Only allow Undo and Apply after merging operations (#699452)
It was possible to make GParted crash by adding a label, check or new
UUID operation and then applying the operation before the view of
pending operations had finished fully opening.  The operation would be
successfully applied but GParted would crash afterwards.

The fault was that Add_Operation() still enabled the Undo and Apply
buttons and processed the GTK event loop before merging the list of
pending operations.  Faulty code flow went like this:

    activate_*()
        Add_Operation()
            Add operation to the operations[] vector
            Enable Undo and Apply buttons
            Refresh_Visual()
                Process GTK event loop
                    Process Apply button callback applying operations,
                    refreshing display and clearing operations[] vector
        Merge operations in the operations[] vector
        << Core dump here >>
            Merge_Operations()
                Refresh_Visual()

This faulty code flow came about when merging of operations was added
and it didn't appreciate that the operations[] vector could have been
processed and cleared by Add_Operations() before the merge step.
Relevant commit:

    b10349ae37
    Merge overlapping operations (#438573)

Fragment of code in the label operation case:

  2454  void Win_GParted::activate_label_partition()
  2455  {
  ...
  2472          Add_Operation( operation ) ;
  2473
  2474          // Verify if the two operations can be merged
  2475          for ( unsigned int t = 0 ; t < operations .size() - 1 ; t++ )
  2476          {
  2477              if ( operations[ t ] ->type == OPERATION_LABEL_PARTITION )
  2478              {
  2479                  if ( Merge_Operations( t, operations .size() - 1 ) )
  2480                      break;
  2481              }
  2482          }

Commentary in the crashing label operation case:

  2472  The pending operation was already applied when Add_Operation()
        returned resulting in the operations[] vector being cleared
        setting its size to 0.
  2475  The return type of operations.size() is an unsigned integral, so
        the upper limit of the for loop is t < 0UL - 1.  Assuming a
        32-bit machine that's t < 4294967295.
  2477  operations[] vector is access from out of bounds offset 0
        upwards until unallocated memory is accessed resulting in a core
        dump.

Fix this by not enabling the Undo and Apply buttons and processing the
GTK event loop until after merging of operations has been performed.
Fixed code flow goes like this:

    activate_*()
        Add_Operation()
            Add operation to the operations[] vector
        Merge operations in the operations[] vector
            Merge_Operations()
        show_operationslist()
            Enable Undo and Apply buttons
            Refresh_Visual()
                Process GTK event loop
                    Process Apply button callback applying operations,
                    refreshing display and clearing operations[] vector

Not allowing the operations list to be process until after the merge
step is the be correct ordering.  This also prevents the new operation
from flashing up in the operations list and then immediately
disappearing if merged.  In the case of adding the first operation,
delaying enabling the Undo and Apply buttons is enough as the buttons
were previously disabled preventing the operation being applied before
the merge.  In the case of adding further operations, processing of the
GTK event loop must also be delayed until after the merge to prevent the
operations being applied before the merge.  Although that window of
opportunity would only be microseconds.

Bug #699452 - Crash when applying operations before pending operations
              fully displayed
2013-05-19 13:18:25 -06:00
..
.cvsignore added *.swp some modifications to pass 'make distcheck' minor cleanups 2005-11-25 12:59:47 +00:00
Copy_Blocks.h Avoid glibmm GSource bug/crash (#697727) 2013-04-17 11:53:55 -06:00
DMRaid.h Remove all usage of kpartx to avoid partition entry duplicates 2011-02-22 14:40:02 -07:00
Device.h Add sector size to device display pane 2010-02-20 15:12:26 -07:00
DialogFeatures.h Add support for setting UUID (#667278) 2012-01-23 12:32:27 -07:00
DialogManageFlags.h improved behaviour of flagmanagementdialog. 2006-04-02 11:18:34 +00:00
Dialog_Base_Partition.h Prevent crash from pressing Esc in dialogs with number entry (#682658) 2012-08-30 13:14:04 -06:00
Dialog_Disklabel.h Bug #634090: Change some attributes to local variables 2011-07-18 13:28:49 -06:00
Dialog_Partition_Copy.h Set sector size and add to operation and dialog methods 2010-04-19 19:22:31 -06:00
Dialog_Partition_Info.h Display unallocated space in the information dialog (#499202) 2012-06-18 10:24:28 -06:00
Dialog_Partition_Label.h Bug #634090: Change some attributes to local variables 2011-07-18 13:28:49 -06:00
Dialog_Partition_New.h Fix unused parameter compiler warning 2011-07-18 13:31:54 -06:00
Dialog_Partition_Resize_Move.h in some places i still used MiB's instead of sectors to store sizes. this 2006-02-25 10:09:30 +00:00
Dialog_Progress.h Fix dialog progress details view size (#602635) (#662722) 2013-03-11 18:40:31 -06:00
Dialog_Rescue_Data.h Added support to lost data recovery using gpart 2011-01-29 14:58:02 -07:00
DrawingAreaVisualDisk.h Simplify main window partition usage graphic code 2012-06-26 14:13:31 -06:00
FS_Info.h Add methods to FS_Info class to get path by uuid and by label 2010-12-09 14:06:38 -07:00
FileSystem.h Pass Partition instead of just its path to FileSystem::copy() 2013-03-11 18:40:31 -06:00
Frame_Resizer_Base.h Limit graphic movement according to required boot record space 2010-05-25 16:26:08 -06:00
Frame_Resizer_Extended.h did lots of work on the resizer, it's behaviour should be more natural and 2006-03-01 19:16:13 +00:00
GParted_Core.h Remove unused function copy_filesystem_simulation() 2013-03-25 10:06:40 -06:00
HBoxOperations.h added popupmenu to operationslist and did some (higrelated) cleanups 2006-09-17 13:23:47 +00:00
LVM2_PV_Info.h Implement common LVM2_PV_Info cache search and index functions 2012-08-30 13:47:46 -06:00
Makefile.am Combine duplicate code for fat16/32 2013-05-17 09:23:56 -06:00
Operation.h Add support for setting UUID (#667278) 2012-01-23 12:32:27 -07:00
OperationChangeUUID.h Add support for setting UUID (#667278) 2012-01-23 12:32:27 -07:00
OperationCheck.h added 'check' operation. The functionality was already there, but it was 2006-11-26 14:27:16 +00:00
OperationCopy.h implemented some stuff to find a good blocksize to use for copy/move. 2006-08-08 19:04:29 +00:00
OperationCreate.h renamed some enums 2006-07-29 15:20:32 +00:00
OperationDelete.h renamed some enums 2006-07-29 15:20:32 +00:00
OperationDetail.h Add proper cancel support (#601239) 2013-03-11 18:40:31 -06:00
OperationFormat.h renamed some enums 2006-07-29 15:20:32 +00:00
OperationLabelPartition.h gparted-0.3.6 - code recreation from Source Forge 2008-04-07 19:41:18 +00:00
OperationResizeMove.h renamed some enums 2006-07-29 15:20:32 +00:00
Partition.h Make GParted recognise reading blank file system labels (#685656) 2012-11-04 12:26:09 +00:00
PipeCapture.h Rename signals update and eof 2013-05-10 10:03:53 -06:00
Proc_Partitions_Info.h Refactor device parsing logic into Proc_Partitions_Info class 2010-12-07 16:01:54 -07:00
TreeView_Detail.h trivial cleanups 2006-09-16 15:00:25 +00:00
Utils.h Add new "cleared" file system format (#688882) 2013-03-25 10:06:39 -06:00
Win_GParted.h Only allow Undo and Apply after merging operations (#699452) 2013-05-19 13:18:25 -06:00
btrfs.h Cleanup duplicate fs code 2013-03-11 18:40:31 -06:00
exfat.h Cleanup duplicate fs code 2013-03-11 18:40:31 -06:00
ext2.h Cleanup duplicate fs code 2013-03-11 18:40:31 -06:00
f2fs.h Add f2fs file system support (#695396) 2013-03-19 22:13:34 +00:00
fat16.h Pad fat16/32 file system labels with spaces (#700228) 2013-05-17 09:23:56 -06:00
hfs.h Cleanup duplicate fs code 2013-03-11 18:40:31 -06:00
hfsplus.h Cleanup duplicate fs code 2013-03-11 18:40:31 -06:00
i18n.h enabled support for reiserfs 2004-10-06 15:32:40 +00:00
jfs.h Cleanup duplicate fs code 2013-03-11 18:40:31 -06:00
linux_swap.h Pass Partition instead of just its path to FileSystem::copy() 2013-03-11 18:40:31 -06:00
lvm2_pv.h Cleanup duplicate fs code 2013-03-11 18:40:31 -06:00
nilfs2.h Cleanup duplicate fs code 2013-03-11 18:40:31 -06:00
ntfs.h Pass Partition instead of just its path to FileSystem::copy() 2013-03-11 18:40:31 -06:00
reiser4.h Cleanup duplicate fs code 2013-03-11 18:40:31 -06:00
reiserfs.h Cleanup duplicate fs code 2013-03-11 18:40:31 -06:00
ufs.h Cleanup duplicate fs code 2013-03-11 18:40:31 -06:00
xfs.h Pass Partition instead of just its path to FileSystem::copy() 2013-03-11 18:40:31 -06:00