Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-doc
Path: blob/main/website/static/security/patches/EN-14:11/crypt.patch
18096 views
1
Index: lib/libcrypt/crypt.c
2
===================================================================
3
--- lib/libcrypt/crypt.c (revision 273303)
4
+++ lib/libcrypt/crypt.c (working copy)
5
@@ -37,8 +37,13 @@ __FBSDID("$FreeBSD$");
6
#include "crypt.h"
7
8
/*
9
- * List of supported crypt(3) formats. The first element in the list will
10
- * be the default.
11
+ * List of supported crypt(3) formats.
12
+ *
13
+ * The default algorithm is the last entry in the list (second-to-last
14
+ * array element since the last is a sentinel). The reason for placing
15
+ * the default last rather than first is that DES needs to be at the
16
+ * bottom for the algorithm guessing logic in crypt(3) to work correctly,
17
+ * and it needs to be the default for backward compatibility.
18
*/
19
static const struct crypt_format {
20
const char *const name;
21
@@ -45,10 +50,6 @@ static const struct crypt_format {
22
char *(*const func)(const char *, const char *);
23
const char *const magic;
24
} crypt_formats[] = {
25
- /* default format */
26
- { "sha512", crypt_sha512, "$6$" },
27
-
28
- /* other supported formats */
29
{ "md5", crypt_md5, "$1$" },
30
#ifdef HAS_BLOWFISH
31
{ "blf", crypt_blowfish, "$2" },
32
@@ -55,6 +56,7 @@ static const struct crypt_format {
33
#endif
34
{ "nth", crypt_nthash, "$3$" },
35
{ "sha256", crypt_sha256, "$5$" },
36
+ { "sha512", crypt_sha512, "$6$" },
37
#ifdef HAS_DES
38
{ "des", crypt_des, "_" },
39
#endif
40
@@ -63,7 +65,8 @@ static const struct crypt_format {
41
{ NULL, NULL, NULL }
42
};
43
44
-static const struct crypt_format *crypt_format = &crypt_formats[0];
45
+static const struct crypt_format *crypt_format =
46
+ &crypt_formats[(sizeof crypt_formats / sizeof *crypt_formats) - 2];
47
48
#define DES_SALT_ALPHABET \
49
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
50
51