]> git.pld-linux.org Git - packages/parted.git/blame - 0111-Tests-case-for-sigsegv-when-false-nilfs2-superblock-.patch
- release 6 (by relup.sh)
[packages/parted.git] / 0111-Tests-case-for-sigsegv-when-false-nilfs2-superblock-.patch
CommitLineData
74a816df
MK
1From 4135de60aaad363644a67c6f52b7ea977a16a7b9 Mon Sep 17 00:00:00 2001
2From: Michael Small <smallm@sdf.org>
3Date: Wed, 13 Feb 2019 16:05:21 -0500
4Subject: [PATCH 111/111] Tests case for sigsegv when false nilfs2 superblock
5 detected.
6
7---
8 tests/Makefile.am | 2 ++
9 tests/t4301-nilfs2-badsb2.sh | 43 +++++++++++++++++++++++++++++
10 tests/t4302-nilfs2-lessbadsb2.sh | 47 ++++++++++++++++++++++++++++++++
11 3 files changed, 92 insertions(+)
12 create mode 100755 tests/t4301-nilfs2-badsb2.sh
13 create mode 100755 tests/t4302-nilfs2-lessbadsb2.sh
14
15diff --git a/tests/Makefile.am b/tests/Makefile.am
16index 3fa75a9..0d7c022 100644
17--- a/tests/Makefile.am
18+++ b/tests/Makefile.am
19@@ -66,6 +66,8 @@ TESTS = \
20 t4100-msdos-starting-sector.sh \
21 t4200-partprobe.sh \
22 t4300-nilfs2-tiny.sh \
23+ t4301-nilfs2-badsb2.sh \
24+ t4302-nilfs2-lessbadsb2.sh \
25 t5000-tags.sh \
26 t6000-dm.sh \
27 t6001-psep.sh \
28diff --git a/tests/t4301-nilfs2-badsb2.sh b/tests/t4301-nilfs2-badsb2.sh
29new file mode 100755
30index 0000000..cef8a9a
31--- /dev/null
32+++ b/tests/t4301-nilfs2-badsb2.sh
33@@ -0,0 +1,43 @@
34+#!/bin/sh
35+# Trigger a nilfs2-related bug.
36+
37+# Copyright (C) 2011-2014 Free Software Foundation, Inc.
38+
39+# This program is free software; you can redistribute it and/or modify
40+# it under the terms of the GNU General Public License as published by
41+# the Free Software Foundation; either version 3 of the License, or
42+# (at your option) any later version.
43+
44+# This program is distributed in the hope that it will be useful,
45+# but WITHOUT ANY WARRANTY; without even the implied warranty of
46+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47+# GNU General Public License for more details.
48+
49+# You should have received a copy of the GNU General Public License
50+# along with this program. If not, see <http://www.gnu.org/licenses/>.
51+
52+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
53+ss=$sector_size_
54+len=32
55+dev=dev-file
56+
57+dd if=/dev/zero of=$dev bs=512 count=$(($len+$ss/512)) || framework_failure_
58+
59+end=$(($len * 512 / $ss))
60+parted -s $dev mklabel msdos mkpart primary 1s ${end}s || framework_failure_
61+
62+# Write a secondary superblock with the nilfs magic number and a nilfs
63+# superblock length (s_bytes) field of only 10 bytes.
64+# struct nilfs2_super_block starts with these four fields...
65+# uint32_t s_rev_level;
66+# uint16_t s_minor_rev_level;
67+# uint16_t s_magic;
68+# uint16_t s_bytes;
69+sb2_offset=$(( 24 / ($ss / 512) + 1))
70+perl -e "print pack 'LSSS.', 0, 0, 0x3434, 10, $ss" |
71+ dd of=$dev bs=$ss seek=$sb2_offset count=1 conv=notrunc
72+
73+# This used to give parted a sigsegv.
74+parted -s $dev print || fail=1
75+
76+Exit $fail
77diff --git a/tests/t4302-nilfs2-lessbadsb2.sh b/tests/t4302-nilfs2-lessbadsb2.sh
78new file mode 100755
79index 0000000..a46dccf
80--- /dev/null
81+++ b/tests/t4302-nilfs2-lessbadsb2.sh
82@@ -0,0 +1,47 @@
83+#!/bin/sh
84+# Trigger a nilfs2-related bug.
85+
86+# Copyright (C) 2011-2014 Free Software Foundation, Inc.
87+
88+# This program is free software; you can redistribute it and/or modify
89+# it under the terms of the GNU General Public License as published by
90+# the Free Software Foundation; either version 3 of the License, or
91+# (at your option) any later version.
92+
93+# This program is distributed in the hope that it will be useful,
94+# but WITHOUT ANY WARRANTY; without even the implied warranty of
95+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96+# GNU General Public License for more details.
97+
98+# You should have received a copy of the GNU General Public License
99+# along with this program. If not, see <http://www.gnu.org/licenses/>.
100+
101+# This test is like t4301-nilfsbadsb2 except with an s_bytes field of
102+# 1024 instead of 10. This exercises a less obvious bug.
103+
104+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
105+ss=$sector_size_
106+len=32
107+dev=dev-file
108+
109+dd if=/dev/zero of=$dev bs=512 count=$(($len+$ss/512)) || framework_failure_
110+
111+end=$(($len * 512 / $ss))
112+parted -s $dev mklabel msdos mkpart primary 1s ${end}s || framework_failure_
113+
114+# Write a secondary superblock with the nilfs magic number and a nilfs
115+# superblock length (s_bytes) field of only 10 bytes.
116+# struct nilfs2_super_block starts with these four fields...
117+# uint32_t s_rev_level;
118+# uint16_t s_minor_rev_level;
119+# uint16_t s_magic;
120+# uint16_t s_bytes;
121+sb2_offset=$(( 24 / ($ss / 512) + 1))
122+perl -e "print pack 'LSSS.', 0, 0, 0x3434, 1024, $ss" |
123+ dd of=$dev bs=$ss seek=$sb2_offset count=1 conv=notrunc
124+
125+# This used to read past the part of the stack allocated by alloca, but
126+# may or may not cause a segmentation fault as a result.
127+parted -s $dev print || fail=1
128+
129+Exit $fail
130--
1312.20.1
132
This page took 0.082748 seconds and 4 git commands to generate.