Re: SHA1 collisions found
- From
René Scharfe <l.s.r@web.de>
- Date
- Feb 27, 2017, 13:29 UTC
- Message-ID
- <13bb2033-fedd-d7da-f584-21a3142852d3@web.de>
- In-Reply-To
- <20170225190410.anvb7ll7tlhwgm3t@genre.crustytoothpaste.net>
Am 25.02.2017 um 20:04 schrieb brian m. carlson:
Show 17 quoted lines
>>> So I think that the current scope left is best estimated by the >>> following command: >>> >>> git grep -P 'unsigned char\s+(\*|.*20)' | grep -v '^Documentation' >>> >>> So there are approximately 1200 call sites left, which is quite a bit of >>> work. I estimate between the work I've done and other people's >>> refactoring work (such as the refs backend refactor), we're about 40% >>> done. > > As a note, I've been working on this pretty much nonstop since the > collision announcement was made. After another 27 commits, I've got it > down from 1244 to 1119. > > I plan to send another series out sometime after the existing series has > hit next. People who are interested can follow the object-id-part* > branches at https://github.com/bk2204/git.
Perhaps the following script can help a bit; it converts local and static variables in specified files. It's just a simplistic parser which can get at least shadowing variables, strings and comments wrong, so its results need to be reviewed carefully.
I failed to come up with an equivalent Coccinelle patch so far. :-/
René
#!/bin/sh
while test $# -gt 0
do
file="$1"
tmp="$file.new"
test -f "$file" &&
perl -e '
use strict;
my %indent;
my %old;
my %new;
my $in_struct = 0;
while (<>) {
if (/^(\s*)}/) {
my $len = length $1;
foreach my $key (keys %indent) {
if ($len < length($indent{$key})) {
delete $indent{$key};
delete $old{$key};
delete $new{$key};
}
}
$in_struct = 0;
}
if (!$in_struct and /^(\s*)(static )?unsigned char (\w+)\[20\];$/) {
my $prefix = "$1$2";
my $name = $3;
$indent{$.} = $1;
$old{$.} = qr/(?<!->)(?<!\.)(?<!-)\b$name\b/;
$name =~ s/sha1/oid/;
print $prefix . "struct object_id " . $name . ";\n";
$new{$.} = $name . ".hash";
next;
}
if (/^(\s*)(static )?struct (\w+ )?\{$/) {
$in_struct = 1;
}
if (!$in_struct and ! /\/\*/) {
foreach my $key (keys %indent) {
s/$old{$key}/$new{$key}/g;
}
}
print;
}
' "$file" >"$tmp" &&
mv "$tmp" "$file" ||
exit 1
shift
done