Skip to content

Commit

Permalink
ProfileCache: Include type in checksum calculation
Browse files Browse the repository at this point in the history
The goal here is to eventually be able to recompute a checksum for the whole profile to verify integrity,
but the current checksums don't include type allowing that to be altered or corrupted without being detected.

N.B. \x1e is the record separator character, used here to delimit the value and type.
  • Loading branch information
jrha committed Nov 28, 2024
1 parent 119241d commit ac4eff9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/perl/Fetch/ProfileCache.pm
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ sub ComputeChecksum
unless (defined $value) {
return md5_hex("_<undef>_");
}
return md5_hex(encode_utf8($value));
return md5_hex(encode_utf8("$value\x1e$type"));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/perl/cli.t
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ like($txt,
"dumpdb output path2eid");
# \0 separated list of subpaths
like($txt,
qr{eid2data:\n0 => a\0c\0e\n10000000 => nlist\n20000000 => 1740877ebcb53b5132e75cff986cd705\n1 => b}m,
qr{eid2data:\n0 => a\0c\0e\n10000000 => nlist\n20000000 => 3ee8d50d6f70735cfd53d9ea92215a22\n1 => b}m,
"dumpdb output eid2data");
like($txt,
qr{path2eid and eid2data combined:\n/ \(0\) =>\n V: a\0c\0e\n T: nlist\n C: 1740877ebcb53b5132e75cff986cd705\n/a \(1\) =>\n},
qr{path2eid and eid2data combined:\n/ \(0\) =>\n V: a\0c\0e\n T: nlist\n C: 3ee8d50d6f70735cfd53d9ea92215a22\n/a \(1\) =>\n},
"dumpdb ouptut combined path2eid eid2data");
diag $txt;

Expand Down

0 comments on commit ac4eff9

Please sign in to comment.