~ubuntu-branches/ubuntu/vivid/parted/vivid

« back to all changes in this revision

Viewing changes to debian/patches/hfs-probe-corrupt.patch

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-07-21 10:23:16 UTC
  • mfrom: (7.2.32 sid)
  • Revision ID: package-import@ubuntu.com-20140721102316-jsyv3yzmbo8vlde5
Tags: 3.1-3
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From a0ab2a3618604db9ecca922c103ed61dd81eb162 Mon Sep 17 00:00:00 2001
2
 
From: "Brian C. Lane" <bcl@redhat.com>
3
 
Date: Fri, 28 Mar 2014 17:10:18 +0000
4
 
Subject: HFS/HFS+ probe: don't let a corrupt FS evoke failed assertion
5
 
 
6
 
Origin: upstream, http://git.debian.org/?p=parted/parted.git;a=commitdiff;h=6bc7e1965078579e9855f851254d67b3d8165784
7
 
Bug-Fedora: http://bugzilla.redhat.com/714758
8
 
Bug-Ubuntu: https://bugs.launchpad.net/bugs/796891
9
 
Forwarded: not-needed
10
 
Last-Update: 2012-03-20
11
 
 
12
 
Patch-Name: hfs-probe-corrupt.patch
13
 
---
14
 
 libparted/fs/hfs/probe.c | 18 +++++++++++-------
15
 
 1 file changed, 11 insertions(+), 7 deletions(-)
16
 
 
17
 
diff --git a/libparted/fs/hfs/probe.c b/libparted/fs/hfs/probe.c
18
 
index e56fef9..6fab79e 100644
19
 
--- a/libparted/fs/hfs/probe.c
20
 
+++ b/libparted/fs/hfs/probe.c
21
 
@@ -83,7 +83,8 @@ hfs_and_wrapper_probe (PedGeometry* geom)
22
 
                  + ((PedSector) PED_BE16_TO_CPU (mdb->total_blocks)
23
 
                     * (PED_BE32_TO_CPU (mdb->block_size) / PED_SECTOR_SIZE_DEFAULT )));
24
 
        max = search + (PED_BE32_TO_CPU (mdb->block_size) / PED_SECTOR_SIZE_DEFAULT);
25
 
-       if (!(geom_ret = ped_geometry_new (geom->dev, geom->start, search + 2)))
26
 
+       if ((search < 0)
27
 
+           || !(geom_ret = ped_geometry_new (geom->dev, geom->start, search + 2)))
28
 
                return NULL;
29
 
 
30
 
        for (; search < max; search++) {
31
 
@@ -142,8 +143,9 @@ hfsplus_probe (PedGeometry* geom)
32
 
                      - 2;
33
 
                search = max - 2 * ( PED_BE32_TO_CPU (vh->block_size)
34
 
                                     / PED_SECTOR_SIZE_DEFAULT ) + 2;
35
 
-               if (!(geom_ret = ped_geometry_new (geom->dev, geom->start,
36
 
-                                                  search + 2)))
37
 
+               if ((search < 0)
38
 
+                   || !(geom_ret = ped_geometry_new (geom->dev, geom->start,
39
 
+                                                     search + 2)))
40
 
                        return NULL;
41
 
 
42
 
                for (; search < max; search++) {
43
 
@@ -157,8 +159,9 @@ hfsplus_probe (PedGeometry* geom)
44
 
                search = ((PedSector) PED_BE32_TO_CPU (vh->total_blocks) - 1)
45
 
                      * ( PED_BE32_TO_CPU (vh->block_size) / PED_SECTOR_SIZE_DEFAULT )
46
 
                      - 1;
47
 
-               if (!ped_geometry_set (geom_ret, geom_ret->start,
48
 
-                                              search + 2)
49
 
+               if ((search < 0)
50
 
+                   || !ped_geometry_set (geom_ret, geom_ret->start,
51
 
+                                         search + 2)
52
 
                    || !ped_geometry_read (geom_ret, buf, search, 1)
53
 
                    || vh->signature != PED_CPU_TO_BE16 (HFSP_SIGNATURE)) {
54
 
                        ped_geometry_destroy (geom_ret);
55
 
@@ -214,8 +217,9 @@ hfsx_probe (PedGeometry* geom)
56
 
                      * ( PED_BE32_TO_CPU (vh->block_size) / PED_SECTOR_SIZE_DEFAULT )
57
 
                      - 2;
58
 
        search = max - ( PED_BE32_TO_CPU (vh->block_size) / PED_SECTOR_SIZE_DEFAULT );
59
 
-       if (!(geom_ret = ped_geometry_new (geom->dev, geom->start,
60
 
-                                          search + 2)))
61
 
+       if ((search < 0)
62
 
+           || !(geom_ret = ped_geometry_new (geom->dev, geom->start,
63
 
+                                             search + 2)))
64
 
                return NULL;
65
 
        for (; search < max; search++) {
66
 
                if (!ped_geometry_set (geom_ret, geom_ret->start,