Skip to content

Commit 605d9d0

Browse files
committed
Merge Release 2.2.3
Revert ill-judged attempt to auto-fix faulty encrypted files with doubled "Salted" prefix #158 The automatic fix for mistakenly double-salted encrypted files seems to be causing file- and system-dependent failures for people, and is almost certainly not worth this hassle, or the performance overhead, since I haven't heard of anyone having a double-salted file to recover. Reverting this now as a bad idea, to return the `smudge` operation back to its original implementation which is massively simpler and hopefully no longer sometimes broken.
1 parent 31d1704 commit 605d9d0

File tree

2 files changed

+19
-30
lines changed

2 files changed

+19
-30
lines changed

CHANGELOG.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@ system, you must also run the `--upgrade` command in each repository:
4343
- When transcrypt refuses to do work in a dirty repository, print a list of
4444
changed files to help the user understand and fix the issue.
4545

46+
### Fixed
47+
48+
- Prevent `cd` commands printing out excess details when `CDPATH` is set (#156)
49+
50+
## [2.2.3] - 2023-03-09
51+
52+
### Fixed
53+
54+
- Revert faulty automatic fix for mistakenly double-salted encrypted files,
55+
which caused more problems than it solved by preventing decryption of some
56+
files on some systems #158
57+
58+
### Changed
59+
60+
- The `hexdump` command is no longer required by Transcrypt.
61+
4662
## [2.2.2] - 2023-03-01
4763

4864
### Changed
@@ -56,7 +72,6 @@ system, you must also run the `--upgrade` command in each repository:
5672
- Avoid null byte warnings when decrypting certain files, caused by a work-
5773
around in 2.2.1 to repair files that could have been incorrectly encrypted
5874
with 2.2.0 due to issue #147
59-
- Prevent `cd` commands printing out excess details when `CDPATH` is set (#156)
6075

6176
## [2.2.1] - 2023-02-11
6277

@@ -297,7 +312,8 @@ Since the v0.9.7 release, these are the notable improvements made to transcrypt:
297312

298313
## [0.9.4] - 2014-03-03
299314

300-
[unreleased]: https://github.com/elasticdog/transcrypt/compare/v2.2.2...HEAD
315+
[unreleased]: https://github.com/elasticdog/transcrypt/compare/v2.2.3...HEAD
316+
[2.2.3]: https://github.com/elasticdog/transcrypt/compare/v2.2.2...v2.2.3
301317
[2.2.2]: https://github.com/elasticdog/transcrypt/compare/v2.2.1...v2.2.2
302318
[2.2.1]: https://github.com/elasticdog/transcrypt/compare/v2.2.0...v2.2.1
303319
[2.2.0]: https://github.com/elasticdog/transcrypt/compare/v2.1.0...v2.2.0

transcrypt

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ git_clean() {
222222
fi
223223
}
224224

225-
# shellcheck disable=SC2005,SC2155
226225
git_smudge() {
227226
tempfile=$(mktemp 2>/dev/null || mktemp -t tmp)
228227
trap 'rm -f "$tempfile"' EXIT
@@ -231,33 +230,7 @@ git_smudge() {
231230
cipher=$(git config --get --local "transcrypt${context_config_group}.cipher")
232231
password=$(load_password "$context_config_group")
233232
openssl_path=$(git config --get --local transcrypt.openssl-path)
234-
235-
# Write stdin to $tempfile, while skimming the first bytes at the same time
236-
local firstbytes=$(tee "$tempfile" | head -c8 | LC_ALL=C tr -d '\0')
237-
# If the first bytes are "Salted", then the file is encrypted
238-
if [[ $firstbytes == "U2FsdGVk" ]]; then
239-
# Fix for file mistakenly encrypted with double "Salted" prefixes due to #147
240-
# that causes garbage characters at top of decrypted files.
241-
#
242-
# Check file header, which we already know starts with "Salted", to see if
243-
# it has exactly the same "Salted__XYZ" prefix mistakenly repeated twice.
244-
# Base64 decode gives raw bytes, hexdump gives bytes as ASCII hex characters.
245-
local header_as_hex=$(echo "$(head -c48 <"$tempfile")" | openssl base64 -d | hexdump -ve '1/1 "%02x"')
246-
local first_salt_prefix=$(echo "$header_as_hex" | cut -b 1-32) # First 32 chars
247-
local maybe_second_salt_prefix=$(echo "$header_as_hex" | cut -b 33-64) # Second 32 chars
248-
249-
# If the salted prefix is repeated -- and not empty, to avoid mistaken match if
250-
# base64 decoding fails -- remove the first occurrence before decrypting...
251-
if [[ "$first_salt_prefix" && "$first_salt_prefix" == "$maybe_second_salt_prefix" ]]; then
252-
openssl base64 -d <"$tempfile" | tail -c+17 | ENC_PASS=$password "$openssl_path" enc -d "-${cipher}" -md MD5 -pass env:ENC_PASS 2>/dev/null
253-
# ...otherwise decrypt as normal
254-
else
255-
ENC_PASS=$password "$openssl_path" enc -d -a "-${cipher}" -md MD5 -pass env:ENC_PASS <"$tempfile" 2>/dev/null
256-
fi
257-
# If the first bytes are not "Salted", the file is not encrypted so output it unchanged
258-
else
259-
cat "$tempfile"
260-
fi
233+
tee "$tempfile" | ENC_PASS=$password "$openssl_path" enc -d "-${cipher}" -md MD5 -pass env:ENC_PASS -a 2>/dev/null || cat "$tempfile"
261234
}
262235

263236
git_textconv() {

0 commit comments

Comments
 (0)