]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix handling of negative bitmap offsets on 64bit hosts.
authorNeil Brown <neilb@suse.de>
Mon, 21 May 2007 04:25:30 +0000 (14:25 +1000)
committerNeil Brown <neilb@suse.de>
Mon, 21 May 2007 04:25:30 +0000 (14:25 +1000)
The bitmap offset is a signed 32bit number, so casting to (long)
isn't sufficient.  We must cast to (int32_t).

ANNOUNCE-2.6.2 [new file with mode: 0644]
super1.c
tests/02lineargrow [new file with mode: 0644]
tests/07autodetect [new file with mode: 0644]

diff --git a/ANNOUNCE-2.6.2 b/ANNOUNCE-2.6.2
new file mode 100644 (file)
index 0000000..e69de29
index efe8a460b75df15b6c6e512df3928039bb8ff351..5995bb6184a81c4dde2816139fe3c4fc61575168 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -215,7 +215,7 @@ static void examine_super1(void *sbv, char *homehost)
        printf("\n");
        if (sb->feature_map & __cpu_to_le32(MD_FEATURE_BITMAP_OFFSET)) {
                printf("Internal Bitmap : %ld sectors from superblock\n",
-                      (long)__le32_to_cpu(sb->bitmap_offset));
+                      (long)(int32_t)__le32_to_cpu(sb->bitmap_offset));
        }
        if (sb->feature_map & __le32_to_cpu(MD_FEATURE_RESHAPE_ACTIVE)) {
                printf("  Reshape pos'n : %llu%s\n", (unsigned long long)__le64_to_cpu(sb->reshape_position)/2,
@@ -1276,7 +1276,7 @@ static void locate_bitmap1(struct supertype *st, int fd, void *sbv)
        sb = sbv;
 
        offset = __le64_to_cpu(sb->super_offset);
-       offset += (long) __le32_to_cpu(sb->bitmap_offset);
+       offset += (int32_t) __le32_to_cpu(sb->bitmap_offset);
        if (mustfree)
                free(sb);
        lseek64(fd, offset<<9, 0);
diff --git a/tests/02lineargrow b/tests/02lineargrow
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/07autodetect b/tests/07autodetect
new file mode 100644 (file)
index 0000000..e69de29