encrypted-file: Extend magic numbers in try_password().
[pspp] / src / data / encrypted-file.c
index f1074b4c1d159d4ad805ea9b887f40400114e20f..27bfe2e3f09c62c89b8f8089b3cf6659ef5efd27 100644 (file)
@@ -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