2020-04-28 09:38:42 +00:00
|
|
|
From 95bbcaa8550534f03b332487ef3a2ed6650424fe Mon Sep 17 00:00:00 2001
|
|
|
|
From: Frantisek Sumsal <frantisek@sumsal.cz>
|
|
|
|
Date: Wed, 21 Aug 2019 11:16:07 +0200
|
|
|
|
Subject: [PATCH] git2spec: avoid malforming of SHA-1 hashes
|
2019-12-17 09:22:28 +00:00
|
|
|
|
2020-04-28 09:38:42 +00:00
|
|
|
When a SHA-1 hash of a specific commit is used as a tag, the regex
|
|
|
|
shenanigans later in the script can (and will) corrupt it in certain
|
|
|
|
cases.
|
|
|
|
|
|
|
|
e.g.:
|
|
|
|
$ perl -e '
|
|
|
|
$tag="6e8cd92261577230daa1098f7e05ec198c3c4281";
|
|
|
|
$tag=~s/[^0-9]+?([0-9]+)/$1/;
|
|
|
|
print("$tag\n");
|
|
|
|
'
|
|
|
|
68cd92261577230daa1098f7e05ec198c3c4281
|
|
|
|
|
|
|
|
(Notice the missing 'e')
|
|
|
|
|
|
|
|
Let's fix this by limiting the regex's scope to a non-SHA-1 tags only.
|
2019-12-17 09:22:28 +00:00
|
|
|
---
|
2020-04-28 09:38:42 +00:00
|
|
|
git2spec.pl | 2 +-
|
|
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
2019-12-17 09:22:28 +00:00
|
|
|
|
2020-04-28 09:38:42 +00:00
|
|
|
diff --git a/git2spec.pl b/git2spec.pl
|
|
|
|
index 7853791e..9ddc3805 100755
|
|
|
|
--- a/git2spec.pl
|
|
|
|
+++ b/git2spec.pl
|
|
|
|
@@ -37,7 +37,7 @@ $tag=`git describe --abbrev=0 --tags` if not defined $tag;
|
|
|
|
chomp($tag);
|
|
|
|
my @patches=&create_patches($tag, $pdir);
|
|
|
|
my $num=$#patches + 2;
|
|
|
|
-$tag=~s/[^0-9]+?([0-9]+)/$1/;
|
|
|
|
+$tag=~s/[^0-9]+?([0-9]+)/$1/ if $tag !~ /\b[0-9a-f]{5,40}\b/;
|
|
|
|
my $release="$num.git$datestr";
|
|
|
|
$release="1" if $num == 1;
|
2019-12-17 09:22:28 +00:00
|
|
|
|
|
|
|
|