Skip to content

Commit f20e664

Browse files
committed
Check gpg version before setting --weak-digest
1 parent 72fb515 commit f20e664

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

contrib/verify-commits/gpg.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,20 @@ else
1919
# an attacker could construct a pull-req that results in a commit object that
2020
# they've created a collision for. Not the most likely attack, but preventing
2121
# it is pretty easy so we do so as a "belt-and-suspenders" measure.
22-
23-
GPG_RES="$(echo "$INPUT" | gpg --trust-model always --weak-digest sha1 "$@" 2>/dev/null)"
22+
GPG_RES=""
23+
for LINE in "$(gpg --version)"; do
24+
case "$LINE" in
25+
"gpg (GnuPG) 1.4.1"*|"gpg (GnuPG) 2.0."*)
26+
echo "Please upgrade to at least gpg 2.1.10 to check for weak signatures" > /dev/stderr
27+
GPG_RES="$(echo "$INPUT" | gpg --trust-model always "$@" 2>/dev/null)"
28+
;;
29+
# We assume if you're running 2.1+, you're probably running 2.1.10+
30+
# gpg will fail otherwise
31+
# We assume if you're running 1.X, it is either 1.4.1X or 1.4.20+
32+
# gpg will fail otherwise
33+
esac
34+
done
35+
[ "$GPG_RES" = "" ] && GPG_RES="$(echo "$INPUT" | gpg --trust-model always --weak-digest sha1 "$@" 2>/dev/null)"
2436
fi
2537
for LINE in $(echo "$GPG_RES"); do
2638
case "$LINE" in
@@ -40,7 +52,7 @@ if ! $VALID; then
4052
exit 1
4153
fi
4254
if $VALID && $REVSIG; then
43-
echo "$INPUT" | gpg --trust-model always "$@" | grep "\[GNUPG:\] \(NEWSIG\|SIG_ID\|VALIDSIG\)" 2>/dev/null
55+
echo "$INPUT" | gpg --trust-model always "$@" 2>/dev/null | grep "\[GNUPG:\] \(NEWSIG\|SIG_ID\|VALIDSIG\)"
4456
echo "$GOODREVSIG"
4557
else
4658
echo "$INPUT" | gpg --trust-model always "$@" 2>/dev/null

contrib/verify-commits/verify-commits.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ IS_SIGNED () {
4343
export BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG=0
4444
fi
4545

46-
if ! git -c "gpg.program=${DIR}/gpg.sh" verify-commit $1 > /dev/null 2>&1; then
46+
if ! git -c "gpg.program=${DIR}/gpg.sh" verify-commit $1 > /dev/null; then
4747
return 1;
4848
fi
4949

0 commit comments

Comments
 (0)