Path: blob/main/website/static/security/patches/EN-14:11/crypt.patch
18096 views
Index: lib/libcrypt/crypt.c1===================================================================2--- lib/libcrypt/crypt.c (revision 273303)3+++ lib/libcrypt/crypt.c (working copy)4@@ -37,8 +37,13 @@ __FBSDID("$FreeBSD$");5#include "crypt.h"67/*8- * List of supported crypt(3) formats. The first element in the list will9- * be the default.10+ * List of supported crypt(3) formats.11+ *12+ * The default algorithm is the last entry in the list (second-to-last13+ * array element since the last is a sentinel). The reason for placing14+ * the default last rather than first is that DES needs to be at the15+ * bottom for the algorithm guessing logic in crypt(3) to work correctly,16+ * and it needs to be the default for backward compatibility.17*/18static const struct crypt_format {19const char *const name;20@@ -45,10 +50,6 @@ static const struct crypt_format {21char *(*const func)(const char *, const char *);22const char *const magic;23} crypt_formats[] = {24- /* default format */25- { "sha512", crypt_sha512, "$6$" },26-27- /* other supported formats */28{ "md5", crypt_md5, "$1$" },29#ifdef HAS_BLOWFISH30{ "blf", crypt_blowfish, "$2" },31@@ -55,6 +56,7 @@ static const struct crypt_format {32#endif33{ "nth", crypt_nthash, "$3$" },34{ "sha256", crypt_sha256, "$5$" },35+ { "sha512", crypt_sha512, "$6$" },36#ifdef HAS_DES37{ "des", crypt_des, "_" },38#endif39@@ -63,7 +65,8 @@ static const struct crypt_format {40{ NULL, NULL, NULL }41};4243-static const struct crypt_format *crypt_format = &crypt_formats[0];44+static const struct crypt_format *crypt_format =45+ &crypt_formats[(sizeof crypt_formats / sizeof *crypt_formats) - 2];4647#define DES_SALT_ALPHABET \48"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"495051