-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·129 lines (115 loc) · 3.39 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·129 lines (115 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#! /bin/sh
#
# Build script for the heartbleed_test.c example.
#
# Author: Mike Bland (mbland@acm.org, http://mike-bland.com/)
# Date: 2014-04-15
# License: Creative Commons Attribution 4.0 International (CC By 4.0)
# http://creativecommons.org/licenses/by/4.0/deed.en_US
# URL: http://goo.gl/erKNJm
#
# What this script does
# ---------------------
# If needed, it will download the OpenSSL source packages and unpack them in
# the current directory, build each version, then build and run
# heartbleed_test.c for each version.
HEARTBLEED_TEST_URL=https://mike-bland.googlecode.com/git/heartbleed/heartbleed_test.c
HEARTBLEED_TEST=$(basename ${HEARTBLEED_TEST_URL} .c)
BUGGY_VERSION=openssl-1.0.1-beta1
FIXED_VERSION=openssl-1.0.1g
OPENSSL_SOURCE_URL=http://www.openssl.org/source/
for version in ${BUGGY_VERSION} ${FIXED_VERSION}
do
tarball=${version}.tar.gz
if test ! -f ${tarball}; then
package=${OPENSSL_SOURCE_URL}${tarball}
echo "Downloading ${package}"
/usr/bin/curl -O ${package}
if test $? -ne 0; then
echo "Failed to download ${package}"
echo "Aborting..."
exit 1
fi
fi
if test ! -d ${version}; then
echo "Unpacking ${tarball}"
/usr/bin/gzip -dc ${tarball} | /usr/bin/tar xf -
if test $? -ne 0; then
echo "Unpacking ${tarball} failed"
echo "Aborting..."
exit 1
fi
fi
done
for version in ${BUGGY_VERSION} ${FIXED_VERSION}
do
echo "Building ${version}..."
pushd ${version}
if ! test -f crypto/buildinf.h; then
if ! ./config; then
echo "Failed to configure ${version}"
echo "Aborting..."
exit 1
fi
fi
if ! make; then
echo "Failed to build ${version}"
echo "Aborting..."
exit 1
fi
popd
done
HEARTBLEED_TEST_FILE=$(basename ${HEARTBLEED_TEST_URL})
if ! test -f ${HEARTBLEED_TEST_FILE}; then
echo "Downloading ${HEARTBLEED_TEST_URL}..."
/usr/bin/curl -O ${HEARTBLEED_TEST_URL}
if test $? -ne 0; then
echo "Failed to download ${HEARTBLEED_TEST_URL}"
echo "Aborting..."
exit 1
fi
echo "Linking ${HEARTBLEED_TEST_FILE} into each version..."
for version in ${BUGGY_VERSION} ${FIXED_VERSION}
do
if ! /bin/ln ${HEARTBLEED_TEST_FILE} ${version}/test; then
echo "Failed to link ${HEARTBLEED_TEST_FILE} into ${version}/test"
echo "Aborting..."
exit 1
fi
done
fi
for version in ${BUGGY_VERSION} ${FIXED_VERSION}
do
echo "Building and executing heartbleed_test for ${version}..."
makefile=${version}/test/Makefile
if grep -q ${HEARTBLEED_TEST} ${makefile}; then
echo "${makefile} already updated..."
else
echo "Adding ${HEARTBLEED_TEST} to ${makefile}..."
/bin/cat >>${makefile} <<END
${HEARTBLEED_TEST}.o: ${HEARTBLEED_TEST}.c
${HEARTBLEED_TEST}: ${HEARTBLEED_TEST}.o \$(DLIBCRYPTO)
@target=${HEARTBLEED_TEST}; \$(BUILD_CMD)
END
if test ! $? -eq 0; then
echo "Failed to append ${HEARTBLEED_TEST} target to ${makefile}"
echo "Aborting..."
exit 1
fi
fi
echo "Building ${HEARTBLEED_TEST} for ${version}..."
pushd ${version}
if ! make TESTS=${HEARTBLEED_TEST} test; then
echo "Failed to build ${HEARTBLEED_TEST} for ${version}"
echo "Aborting..."
exit 1
fi
popd
test_program=${version}/test/heartbleed_test
echo "******** EXECUTING ${test_program} ********"
result="PASSED"
if ! ${test_program}; then
result="FAILED"
fi
echo "******** ${test_program} ${result} ********"
done