From: Ben Pfaff Date: Sat, 12 Jan 2019 20:14:36 +0000 (-0800) Subject: encrypted-file: Extend magic numbers in try_password(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=b86361a1fe04710f9622145da6ca0e7981330c78 encrypted-file: Extend magic numbers in try_password(). The three-byte magic numbers would match 1 in about every 16 million guessed passwords, which is too frequent for exhaustive testing. The new 7- and 10-byte magic numbers should not have the same problem. --- diff --git a/src/data/encrypted-file.c b/src/data/encrypted-file.c index f1074b4c1d..27bfe2e3f0 100644 --- a/src/data/encrypted-file.c +++ b/src/data/encrypted-file.c @@ -348,7 +348,12 @@ try_password(struct encrypted_file *f, const char *password) rijndaelDecrypt (f->rk, f->Nr, CHAR_CAST (const char *, f->ciphertext), CHAR_CAST (char *, f->plaintext)); - return !memcmp (f->plaintext, f->type == SYSTEM ? "$FL" : "* E", 3); + + const char *magic = f->type == SYSTEM ? "$FL?@(#)" : "* Encoding"; + for (int i = 0; magic[i]; i++) + if (magic[i] != '?' && f->plaintext[i] != magic[i]) + return false; + return true; } static bool