bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rescue command segv's always


From: K.G.
Subject: Re: rescue command segv's always
Date: Wed, 16 Nov 2005 23:01:27 +0100

Many thanks for your perfect bug report. The following patch
probably fix the problem.

Cheers,
Guillaume Knispel


Index: parted/ui.c
===================================================================
--- parted/ui.c (revision 483)
+++ parted/ui.c (working copy)
@@ -559,18 +559,21 @@
         * default.
         */
        if (input && *value && !strcmp (input, def_str)) {
-               *range = ped_geometry_new (dev, *value, 1);
-               PED_ASSERT (*range != NULL, return 0);
+               if (range) {
+                       *range = ped_geometry_new (dev, *value, 1);
+                       ped_free (def_str);
+                       return *range != NULL;
+               }
 
                ped_free (def_str);
-
                return 1;
        }
 
        ped_free (def_str);
        if (!input) {
                *value = 0;
-               *range = NULL;
+               if (range)
+                       *range = NULL;
                return 0;
        }
 
Index: libparted/unit.c
===================================================================
--- libparted/unit.c    (revision 483)
+++ libparted/unit.c    (working copy)
@@ -352,15 +352,17 @@
                                str, dev->path);
                goto error_free_copy;
        }
-       *range = ped_geometry_new (dev, *sector, 1);
+       if (range)
+               *range = ped_geometry_new (dev, *sector, 1);
        ped_free (copy);
-       return 1;
+       return !range || *range != NULL;
 
 error_free_copy:
        ped_free (copy);
 error:
        *sector = 0;
-       *range = NULL;
+       if (range)
+               *range = NULL;
        return 0;
 }
 
@@ -455,26 +457,28 @@
        /* negative numbers count from the end */
        if (copy[0] == '-')
                *sector += dev->length;
-       *range = geometry_from_centre_radius (dev, *sector, radius);
-       if (!*range) {
-               ped_exception_throw (
-                       PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
-                       _("The location %s is outside of the device %s."),
-                       str, dev->path);
-               goto error_free_copy;
+       if (range) {
+               *range = geometry_from_centre_radius (dev, *sector, radius);
+               if (!*range) {
+                       ped_exception_throw (
+                               PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+                               _("The location %s is outside of the "
+                                 "device %s."),
+                               str, dev->path);
+                       goto error_free_copy;
+               }
        }
        *sector = clip (dev, *sector);
 
        ped_free (copy);
        return 1;
 
-error_destroy_range:
-       ped_geometry_destroy (*range);
 error_free_copy:
        ped_free (copy);
 error:
        *sector = 0;
-       *range = NULL;
+       if (range)
+               *range = NULL;
        return 0;
 }
 









On Wed, 16 Nov 2005 13:46:19 -0600 Ryan Charles Underwood <address@hidden> 
wrote:
> Hi, I am attempting to rescue a deleted ext3 partition.  The deleted 
> partition was hda11 and started at 5006*8225280.  Here is what I 
> get (with latest parted):
> 
> parted /dev/hda
> GNU Parted 1.6.25.1
> Copyright (C) 1998 - 2005 Free Software Foundation, Inc.
> This program is free software, covered by the GNU General Public License.
> 
> This program is distributed in the hope that it will be useful, but 
> WITHOUT ANY
> WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
> FOR A
> PARTICULAR PURPOSE.  See the GNU General Public License for more details.
> 
> Using /dev/hda
> (parted) p                                                                
> Disk geometry for /dev/hda: 0kB - 250GB
> Disk label type: msdos
> Number  Start   End     Size    Type      File system  Flags
> 1       32kB    3989MB  3989MB  primary   ntfs         hidden
> 2       3989MB  8003MB  4014MB  primary                boot
> 3       8003MB  12GB    3989MB  primary                lba
> 4       12GB    250GB   238GB   extended               
> 5       12GB    16GB    3997MB  logical                
> 6       16GB    17GB    1003MB  logical   ext3         
> 7       17GB    25GB    8003MB  logical   ext3         
> 8       25GB    33GB    8003MB  logical   ext3         
> 9       33GB    41GB    8003MB  logical   ext3         
> (parted) rescue                                                           
> Start? 41gb                                                               
> Segmentation fault
> 
> It actually does not matter the start location, no matter what I choose
> the result is always a segv.  Using valgrind the problem is shown to be 
> here:
> ==19027== Invalid write of size 4
> ==19027==    at 0x1B925F56: ped_unit_parse_custom (in 
> /lib/libparted-1.6.so.13.11.0)
> ==19027==    by 0x1B92615E: ped_unit_parse (in 
> /lib/libparted-1.6.so.13.11.0)
> ==19027==    by 0x8050C70: command_line_get_sector (in 
> /home/nemesis/t/parted-1.6.25.1/parted/.libs/parted)
> ==19027==    by 0x804D5C0: do_rescue (in 
> /home/nemesis/t/parted-1.6.25.1/parted/.libs/parted)
> ==19027==    by 0x804AA87: command_run (in 
> /home/nemesis/t/parted-1.6.25.1/parted/.libs/parted)
> ==19027==    by 0x8051D01: interactive_mode (in 
> /home/nemesis/t/parted-1.6.25.1/parted/.libs/parted)
> ==19027==    by 0x804F335: main (in 
> /home/nemesis/t/parted-1.6.25.1/parted/.libs/parted)
> ==19027==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
> 
> 
> =============================================================
> Here is the diagnostic information:
> parted /dev/hda print unit s print unit chs print
> Disk geometry for /dev/hda: 0kB - 250GB
> Disk label type: msdos
> Number  Start   End     Size    Type      File system  Flags
> 1       32kB    3989MB  3989MB  primary   ntfs         hidden
> 2       3989MB  8003MB  4014MB  primary                boot
> 3       8003MB  12GB    3989MB  primary                lba
> 4       12GB    250GB   238GB   extended               
> 5       12GB    16GB    3997MB  logical                
> 6       16GB    17GB    1003MB  logical   ext3         
> 7       17GB    25GB    8003MB  logical   ext3         
> 8       25GB    33GB    8003MB  logical   ext3         
> 9       33GB    41GB    8003MB  logical   ext3         
> Disk geometry for /dev/hda: 0s - 488397167s
> Disk label type: msdos
> Number  Start   End     Size    Type      File system  Flags
> 1       63s     7791524s 7791462s primary   ntfs         hidden
> 2       7791525s 15631244s 7839720s primary                boot
> 3       15631245s 23422769s 7791525s primary                lba
> 4       23422770s 488392064s 464969295s extended               
> 5       23422833s 31230359s 7807527s logical                
> 6       31230361s 33190289s 1959929s logical   ext3         
> 7       33190291s 48821534s 15631244s logical   ext3         
> 8       48821536s 64452779s 15631244s logical   ext3         
> 9       64452781s 80084024s 15631244s logical   ext3         
> Disk geometry for /dev/hda: 0,0,0 - 30401,80,62
> BIOS cylinder,head,sector geometry: 30401,255,63.  Each cylinder is 
> 8225kB.
> Disk label type: msdos
> Number  Start       End         Type      File system  Flags
> 1       0,1,0       484,254,62  primary   ntfs         hidden
> 2       485,0,0     972,254,62  primary                boot
> 3       973,0,0     1457,254,62 primary                lba
> 4       1458,0,0    30400,254,62 extended               
> 5       1458,1,0    1943,254,62 logical                
> 6       1944,0,1    2065,254,62 logical   ext3         
> 7       2066,0,1    3038,254,62 logical   ext3         
> 8       3039,0,1    4011,254,62 logical   ext3         
> 9       4012,0,1    4984,254,62 logical   ext3         
> Information: Don't forget to update /etc/fstab, if necessary.             
> 
> 
> fdisk -l -u /dev/hda
> 
> Disk /dev/hda: 250.0 GB, 250059350016 bytes
> 255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
> Units = sectors of 1 * 512 = 512 bytes
> 
>    Device Boot      Start         End      Blocks   Id  System
> /dev/hda1              63     7791524     3895731   17  Hidden HPFS/NTFS
> /dev/hda2   *     7791525    15631244     3919860    7  HPFS/NTFS
> /dev/hda3        15631245    23422769     3895762+   c  W95 FAT32 (LBA)
> /dev/hda4        23422770   488392064   232484647+   5  Extended
> /dev/hda5        23422833    31230359     3903763+  eb  BeOS fs
> /dev/hda6        31230361    33190289      979964+  83  Linux
> /dev/hda7        33190291    48821534     7815622   83  Linux
> /dev/hda8        48821536    64452779     7815622   83  Linux
> /dev/hda9        64452781    80084024     7815622   83  Linux
> 
> 
> 
> _______________________________________________
> Bug-parted mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/bug-parted




reply via email to

[Prev in Thread] Current Thread [Next in Thread]