[Parted-commits] GNU Parted Official Repository: Changes to 'next'
Jim Meyering
meyering at alioth.debian.org
Wed Oct 28 15:41:33 UTC 2009
libparted/disk.c | 13 +--
libparted/labels/loop.c | 6 -
parted/parted.c | 11 +-
tests/Makefile.am | 5 -
tests/t1000-mkpartfs.sh | 70 -----------------
tests/t1500-small-ext2.sh | 64 ---------------
tests/t2000-mkfs.sh | 152 -------------------------------------
tests/t3000-constraints.sh | 54 -------------
tests/t3100-resize-ext2-partion.sh | 55 -------------
tests/t7000-scripting.sh | 8 -
10 files changed, 20 insertions(+), 418 deletions(-)
New commits:
commit 399f89cb70a257323a14b17bde9ee868a6fd8075
Author: Jim Meyering <meyering at redhat.com>
Date: Wed Oct 28 16:40:07 2009 +0100
ui: plug multiple command_line_get_word leaks
* parted/parted.c (do_mkpart, do_print):
diff --git a/parted/parted.c b/parted/parted.c
index 79e50ad..17e94ef 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -836,6 +836,7 @@ do_mkpart (PedDevice** dev)
/* set minor attributes */
if (part_name)
PED_ASSERT (ped_partition_set_name (part, part_name), return 0);
+ free (part_name);
if (!ped_partition_set_system (part, fs_type))
goto error_destroy_disk;
if (ped_partition_is_flag_available (part, PED_PARTITION_LBA))
@@ -867,6 +868,7 @@ error_remove_part:
error_destroy_simple_constraints:
ped_partition_destroy (part);
error_destroy_disk:
+ free (part_name);
ped_disk_destroy (disk);
error:
if (range_start != NULL)
@@ -1311,16 +1313,19 @@ do_print (PedDevice** dev)
peek_word = command_line_peek_word ();
if (peek_word) {
if (strncmp (peek_word, "devices", 7) == 0) {
- command_line_pop_word();
+ char *w = command_line_pop_word();
+ free (w);
has_devices_arg = 1;
}
else if (strncmp (peek_word, "free", 4) == 0) {
- command_line_pop_word ();
+ char *w = command_line_pop_word ();
+ free (w);
has_free_arg = 1;
}
else if (strncmp (peek_word, "list", 4) == 0 ||
strncmp (peek_word, "all", 3) == 0) {
- command_line_pop_word();
+ char *w = command_line_pop_word();
+ free (w);
has_list_arg = 1;
}
else
commit 0bbeb3d1f2973076152f25d63f0335f51dc4e883
Author: Jim Meyering <meyering at redhat.com>
Date: Wed Oct 28 16:37:07 2009 +0100
check: plug an even smaller (formatted "unit") leak
* libparted/disk.c (ped_disk_check): Free fs_size also upon success.
diff --git a/libparted/disk.c b/libparted/disk.c
index bdf251a..beb0921 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -595,7 +595,7 @@ ped_disk_check (const PedDisk* disk)
max_length_error = PED_MAX (4096, walk->geom.length / 100);
bool ok = (ped_geometry_test_inside (&walk->geom, geom)
&& length_error <= max_length_error);
- char* fs_size = ped_unit_format (disk->dev, geom->length);
+ char *fs_size = ped_unit_format (disk->dev, geom->length);
ped_geometry_destroy (geom);
if (!ok) {
char* part_size = ped_unit_format (disk->dev,
@@ -614,6 +614,7 @@ ped_disk_check (const PedDisk* disk)
if (choice != PED_EXCEPTION_IGNORE)
return 0;
}
+ free (fs_size);
}
return 1;
commit 9b610d02c2bece00e02a394bfefebdb26a0de84c
Author: Jim Meyering <meyering at redhat.com>
Date: Wed Oct 28 16:19:43 2009 +0100
check: plug a geometry-sized leak
* libparted/disk.c (ped_disk_check): Destroy "geom", when done with it.
diff --git a/libparted/disk.c b/libparted/disk.c
index f3074a3..bdf251a 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -593,12 +593,14 @@ ped_disk_check (const PedDisk* disk)
length_error = abs (walk->geom.length - geom->length);
max_length_error = PED_MAX (4096, walk->geom.length / 100);
- if (!ped_geometry_test_inside (&walk->geom, geom)
- || length_error > max_length_error) {
- char* part_size = ped_unit_format (disk->dev, walk->geom.length);
- char* fs_size = ped_unit_format (disk->dev, geom->length);
+ bool ok = (ped_geometry_test_inside (&walk->geom, geom)
+ && length_error <= max_length_error);
+ char* fs_size = ped_unit_format (disk->dev, geom->length);
+ ped_geometry_destroy (geom);
+ if (!ok) {
+ char* part_size = ped_unit_format (disk->dev,
+ walk->geom.length);
PedExceptionOption choice;
-
choice = ped_exception_throw (
PED_EXCEPTION_WARNING,
PED_EXCEPTION_IGNORE_CANCEL,
commit 336987ed75fcde32ad00e5aa596622ebc46d4b96
Author: Jim Meyering <meyering at redhat.com>
Date: Wed Oct 28 16:03:11 2009 +0100
loop: don't leak a sector in loop_clobber
* libparted/labels/loop.c (loop_clobber): Replace leaky open-coded
version with a use of Use ptt_clear_sectors.
diff --git a/libparted/labels/loop.c b/libparted/labels/loop.c
index dc1a86e..b08a04e 100644
--- a/libparted/labels/loop.c
+++ b/libparted/labels/loop.c
@@ -78,14 +78,10 @@ static int
loop_clobber (PedDevice* dev)
{
PED_ASSERT (dev != NULL, return 0);
- char *buf = ped_malloc (dev->sector_size);
- PED_ASSERT (buf != NULL, return 0);
-
- memset (buf, 0, dev->sector_size);
PedSector i = 0;
while (loop_probe (dev)) {
- if (!ped_device_write (dev, buf, i++, 1))
+ if (!ptt_clear_sectors (dev, i++, 1))
return 0;
}
return 1;
commit ca04f5998eb8986df71d51d9e0e76200fdc230b5
Author: Jim Meyering <meyering at redhat.com>
Date: Fri Sep 18 08:40:54 2009 +0200
tests: t7000: remove mkpartfs tests
This test tested both mkpart and mkpartfs.
* tests/t7000-scripting.sh: Remove the mkpartfs tests.
diff --git a/tests/t7000-scripting.sh b/tests/t7000-scripting.sh
index 21cd344..1a70c1e 100755
--- a/tests/t7000-scripting.sh
+++ b/tests/t7000-scripting.sh
@@ -45,11 +45,9 @@ normalize_part_diag_ errS || fail=1
sed s/Error/Warning/ errS
printf 'Is this still acceptable to you?\nYes/No?'; } >> errI || fail=1
-for mkpart in mkpart mkpartfs; do
- # With larger sector size, skip FS-related use of mkpartfs.
- test $sector_size_ -gt 512 && test $mkpart = mkpartfs && continue
+for mkpart in mkpart; do
- # Test for mkpart/mkpartfs in scripting mode
+ # Test for mkpart in scripting mode
test_expect_success \
'Create the test file' \
'dd if=/dev/zero of=testfile bs=${ss}c count=$N 2> /dev/null'
@@ -65,7 +63,7 @@ for mkpart in mkpart mkpartfs; do
compare out errS
'
- # Test mkpart/mkpartfsin interactive mode.
+ # Test mkpart interactive mode.
test_expect_success \
'Create the test file' \
'
commit 93452cdf860f8bd46ff4dc00bc23821d0e683ed8
Author: Jim Meyering <meyering at redhat.com>
Date: Thu Sep 17 20:12:50 2009 +0200
tests: remove tests that are too FS-centric
* tests/t1000-mkpartfs.sh: Remove file.
* tests/t1500-small-ext2.sh: Likewise.
* tests/t2000-mkfs.sh: Likewise.
* tests/t3100-resize-ext2-partion.sh: Likewise.
* tests/t3000-constraints.sh: Likewise.
* tests/Makefile.am (TESTS): Remove them here, too.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0d393a6..e2078b9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -10,16 +10,11 @@ TESTS = \
t0280-gpt-corrupt.sh \
t0300-dos-on-gpt.sh \
t0400-loop-clobber-infloop.sh \
- t1000-mkpartfs.sh \
t1100-busy-label.sh \
- t1500-small-ext2.sh \
t1700-ext-probe.sh \
- t2000-mkfs.sh \
t2100-mkswap.sh \
t2200-dos-label-recog.sh \
t2300-dos-label-extended-bootcode.sh \
- t3000-constraints.sh \
- t3100-resize-ext2-partion.sh \
t4000-sun-raid-type.sh \
t4100-msdos-partition-limits.sh \
t4100-dvh-partition-limits.sh \
diff --git a/tests/t1000-mkpartfs.sh b/tests/t1000-mkpartfs.sh
deleted file mode 100755
index 96bb274..0000000
--- a/tests/t1000-mkpartfs.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2007, 2009 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-
-# 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.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-test_description='Create some file systems using mkpartfs.'
-
-: ${srcdir=.}
-. $srcdir/test-lib.sh
-
-require_512_byte_sector_size_
-
-N=500k
-dev=loop-file
-test_expect_success \
- 'create a file too small to hold a fat32 file system' \
- 'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
-
-test_expect_success \
- 'label the test disk' \
- 'parted -s $dev mklabel msdos > out 2>&1'
-test_expect_success 'expect no output' 'compare out /dev/null'
-
-# Expect parted's mkpartfs command to fail.
-test_expect_failure \
- 'try/fail to create a file system in too small a space' \
- 'parted -s $dev mkpartfs primary fat32 0 1 > out 2>&1'
-
-test_expect_success \
- 'create expected output file' \
- 'echo "Error: Partition too big/small for a fat32 file system." > exp'
-
-test_expect_success \
- 'check for expected failure diagnostic' \
- 'compare out exp'
-
-test_expect_success 'clean up, preparing for next test' 'rm $dev out'
-
-#====================================================================
-# Similar, but with a file that's large enough, so mkpartfs succeeds.
-N=40M
-
-test_expect_success \
- 'create a file large enough to hold a fat32 file system' \
- 'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
-
-test_expect_success \
- 'label the test disk' \
- 'parted -s $dev mklabel msdos > out 2>&1'
-test_expect_success 'expect no output' 'compare out /dev/null'
-
-test_expect_success \
- 'create an msdos file system' \
- 'parted -s $dev mkpartfs primary fat32 1 40 > out 2>&1'
-
-test_expect_success 'expect no output' 'compare out /dev/null'
-
-test_done
diff --git a/tests/t1500-small-ext2.sh b/tests/t1500-small-ext2.sh
deleted file mode 100755
index c07d3f8..0000000
--- a/tests/t1500-small-ext2.sh
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2007, 2009 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-
-# 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.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-test_description='Create very small ext2 file systems.'
-
-: ${srcdir=.}
-. $srcdir/test-lib.sh
-
-require_512_byte_sector_size_
-
-dev=loop-file
-test_expect_success \
- 'setup' '
- dd if=/dev/null of=$dev bs=1 seek=10M 2> /dev/null &&
- parted -s $dev mklabel msdos'
-
-test_expect_failure \
- 'try to create an ext2 partition that is one byte too small' '
- parted -s $dev mkpartfs primary ext2 10KB 29695B > out 2>&1'
-
-test_expect_success \
- 'check for expected diagnostic' '
- echo Error: File system too small for ext2. > exp &&
- compare out exp'
-
-test_expect_success \
- 'create the smallest ext2 partition' '
- parted -s $dev mkpartfs primary ext2 10KB 29696B > out 2>&1
- compare out /dev/null'
-
-# Restore $dev to initial state by writing 1KB of zeroes at the beginning.
-# Then relabel.
-test_expect_success \
- 'setup' '
- dd if=/dev/zero of=$dev bs=1K count=1 conv=notrunc 2> /dev/null &&
- parted -s $dev mklabel msdos'
-
-test_expect_success \
- 'create another ext2 file system (this would fail for parted-1.8.7)' '
- parted -s $dev mkpartfs primary ext2 2 10 > out 2>&1'
-test_expect_success 'expect no output' 'compare out /dev/null'
-
-test_expect_success \
- 'create a smaller one; this would succeed for parted-1.8.7' '
- dd if=/dev/zero of=$dev bs=1K count=1 conv=notrunc 2> /dev/null &&
- parted -s $dev mklabel msdos &&
- parted -s $dev mkpartfs primary ext2 2 9 > out 2>&1'
-test_expect_success 'expect no output' 'compare out /dev/null'
-
-test_done
diff --git a/tests/t2000-mkfs.sh b/tests/t2000-mkfs.sh
deleted file mode 100755
index faf80a7..0000000
--- a/tests/t2000-mkfs.sh
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2007, 2009 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-
-# 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.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-test_description='Create some file systems using mkfs.'
-
-: ${srcdir=.}
-. $srcdir/test-lib.sh
-
-require_512_byte_sector_size_
-
-N=40M
-dev=loop-file
-test_expect_success \
- 'create a file large enough to hold a fat32 file system' \
- 'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
-
-test_expect_success \
- 'label the test disk' \
- 'parted -s $dev mklabel msdos > out 2>&1'
-test_expect_success 'expect no output' 'compare out /dev/null'
-
-test_expect_success \
- 'create a partition' \
- 'parted -s $dev mkpart primary 1 40 > out 2>&1'
-
-test_expect_success \
- 'create an msdos file system' \
- 'parted -s $dev mkfs 1 fat32 > out 2>&1'
-
-test_expect_success 'expect no output' 'compare out /dev/null'
-
-N=10M
-test_expect_success \
- 'create a file large enough to hold a fat32 file system' \
- 'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
-
-test_expect_success \
- 'label the test disk' \
- 'parted -s $dev mklabel msdos > out 2>&1'
-test_expect_success 'expect no output' 'compare out /dev/null'
-
-# test if can create a partition and a filesystem in the same session.
-fail=0
-cat <<EOF >in || fail=1
-mkpart
-primary
-ext2
-0
-10
-mkfs
-No
-quit
-EOF
-test_expect_success 'create input file' 'test $fail = 0'
-
-test_expect_success \
- 'create a partition and a filesystem in the same session' \
- 'parted ---pretend-input-tty $dev < in > out 2>&1'
-
-test_expect_success \
- 'normalize the actual output' \
- 'sed -n "s/.*\(Warning: The existing.*\)$/\1/p" out > out2'
-
-test_expect_success \
- 'check for expected prompt' \
- 'echo "Warning: The existing file system will be destroyed and all" \
- "data on the partition will be lost. Do you want to continue?" > exp &&
- compare out2 exp'
-
-#############################################################
-# Ensure that an invalid file system type elicits a diagnostic.
-# Before parted 1.8.8, this would fail silently.
-
-dev=loop-file
-
-test_expect_success \
- "setup: create and label a device" \
- 'dd if=/dev/null of=$dev bs=1 seek=1M 2>/dev/null &&
- parted -s $dev mklabel msdos'
-
-test_expect_failure \
- 'try to create a file system with invalid type name' \
- 'parted -s $dev mkpartfs primary bogus 1 1 >out 2>&1'
-
-test_expect_success \
- 'normalize the actual output' \
- 'mv out o2 && sed -e "s,
*
,,;s, $,," \
- -e "s,^.*/lt-parted: ,parted: ," o2 > out'
-
-test_expect_success \
- 'check for expected diagnostic' \
- '{ echo "parted: invalid token: bogus"
- echo "Error: Expecting a file system type."; } > exp &&
- compare out exp'
-
-#############################################################
-# Demonstrate 3-block-group failure for 16+MB EXT2 file system.
-# This test would fail with parted-1.8.7.
-
-dev=loop-file
-
-mkfs()
-{
- size=$1
- test_expect_success \
- "setup: create and label a device" \
- 'dd if=/dev/null of=$dev bs=1 seek=30M 2>/dev/null &&
- parted -s $dev mklabel gpt'
-
- test_expect_success \
- "try to create an ext2 file system of size $size" \
- 'parted -s $dev mkpartfs primary ext2 0 ${size}B >out 2>&1'
- test_expect_success 'check for empty output' 'compare out /dev/null'
-}
-
-
-# size in bytes #block groups last_group_blocks (in ext2_mkfs)
-mkfs 16795000 # 2 8191
-mkfs 16796000 # 2 8192
-mkfs 16796160 # 2 (was 3) 1
-mkfs 16797000 # 2 (was 3) 1
-mkfs 16798000 # 2 (was 3) 2
-# ...
-mkfs 17154000 # 2 (was 3) 350
-mkfs 17155000 # 2 (was 3) 351 last_group_admin == last_group_blocks
-mkfs 17156000 # 2 (was 3) 352
-mkfs 17157000 # 3 353
-mkfs 17158000 # 3 354
-# ...
-mkfs 25184000 # 3 8192
-mkfs 25185000 # 3 (was 4) 1 (last_group_admin = 387)
-mkfs 25186000 # 3 (was 4) 2 (last_group_admin = 387)
-# ...
-mkfs 25589000 # 3 (was 4) 394 (last_group_admin = 394)
-mkfs 25589000 # 3 (was 4) 395 (last_group_admin = 394)
-mkfs 25590000 # 4 396
-
-test_done
diff --git a/tests/t3000-constraints.sh b/tests/t3000-constraints.sh
deleted file mode 100755
index 1673b09..0000000
--- a/tests/t3000-constraints.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2007-2009 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-
-# 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.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-test_description="exercise Parted's constraint-management code"
-
-: ${srcdir=.}
-. $srcdir/test-lib.sh
-
-require_512_byte_sector_size_
-
-dev=loop-file
-N=2
-t=ext2
-
-test_expect_success \
- "setup: label and create a small $t partition" \
- 'dd if=/dev/null of=$dev bs=1 seek=${N}M 2>/dev/null &&
- { echo y; echo c; } > in &&
- { emit_superuser_warning
- echo "Warning: You requested a partition from 1000kB to 2000kB."
- echo "The closest location we can manage is 15.9kB to 15.9kB."
- echo "Is this still acceptable to you?"
- echo "Yes/No? y"
- echo "Error: File system too small for ext2."; } > exp &&
- parted -s $dev mklabel msdos &&
- parted -s $dev mkpartfs primary $t 1 $N'
-
-# Before parted-1.9, this would fail with a buffer overrun
-# leading to a segfault.
-test_expect_failure \
- 'try to create another partition in the same place' \
- 'parted ---pretend-input-tty $dev mkpartfs primary $t 1 $N <in >out 2>&1'
-
-test_expect_success \
- 'normalize the actual output' \
- 'sed "s,
*
,,;s, $,," out > o2 && mv -f o2 out'
-
-test_expect_success 'check for expected output' 'compare out exp'
-
-test_done
diff --git a/tests/t3100-resize-ext2-partion.sh b/tests/t3100-resize-ext2-partion.sh
deleted file mode 100755
index d1f47d8..0000000
--- a/tests/t3100-resize-ext2-partion.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/sh
-# Exercise an EXT2-resizing bug.
-
-# Copyright (C) 2007, 2009 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-
-# 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.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-test_description='Exercise an EXT2-resize bug in at least 1.8.7'
-
-: ${srcdir=.}
-. $srcdir/test-lib.sh
-
-require_512_byte_sector_size_
-
-dev=loop-file
-# The "device size", $N, must be larger than $NEW_SIZE.
-N=1500M
-
-# To trigger the bug, the target size must be 269M or larger.
-NEW_SIZE=269M
-
-# $ORIG_SIZE may be just about anything smaller than $NEW_SIZE.
-ORIG_SIZE=1M
-
-test_expect_success \
- 'create the test file' \
- 'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
-
-test_expect_success \
- 'run parted -s FILE mklabel msdos' \
- 'parted -s $dev mklabel msdos > out 2>&1'
-test_expect_success 'check for empty output' 'compare out /dev/null'
-
-test_expect_success \
- 'make an ext2 primary partition' \
- 'parted -s $dev mkpartfs primary ext2 0 $ORIG_SIZE > out 2>&1'
-test_expect_success 'check for empty output' 'compare out /dev/null'
-
-test_expect_success \
- 'resize ext2 primary partition' \
- 'parted -s $dev resize 1 0 $NEW_SIZE > out 2>&1'
-test_expect_success 'check for empty output' 'compare out /dev/null'
-
-test_done
More information about the Parted-commits
mailing list