1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
Patch limits salt for crypt command by two bytes, and for md5crypt
by eight bytes (instead of two). Also, it retains $1$ magic prefix
in md5crypt command result.
@@ -27,6 +27,7 @@
* CVS: $Id: crypt.c,v 1.7 2000/11/18 22:42:31 aku Exp $
*/
+#include <crypt.h>
#include "loadman.h"
static int
@@ -70,6 +71,7 @@
#else
const char* passwd;
const char* salt;
+ char salt_b [3];
Tcl_Obj* res;
if (objc != 3) {
@@ -82,11 +84,17 @@
passwd = Tcl_GetStringFromObj (objv [1], NULL);
salt = Tcl_GetStringFromObj (objv [2], NULL);
+ /* 1) We need only the first two bytes of salt;
+ * 2) Avoiding use of md5_crypt if salt starts with $1$ (as in glibc) */
+ salt_b [0] = salt [0];
+ salt_b [1] = salt [1];
+ salt_b [2] = '\0';
+
/* THREADING: Serialize access to result string of 'crypt'.
*/
TrfLock;
- res = Tcl_NewStringObj ((char*) crypt (passwd, salt), -1);
+ res = Tcl_NewStringObj ((char*) crypt (passwd, salt_b), -1);
TrfUnlock;
Tcl_SetObjResult (interp, res);
@@ -124,7 +132,7 @@
const char* passwd;
const char* salt;
- char salt_b [6];
+ char salt_b [12];
Tcl_Obj* res;
if (TrfLoadMD5 (interp) != TCL_OK) {
@@ -152,13 +160,19 @@
salt_b [2] = '$';
salt_b [3] = salt [0];
salt_b [4] = salt [1];
- salt_b [5] = '\0';
+ salt_b [5] = salt [2];
+ salt_b [6] = salt [3];
+ salt_b [7] = salt [4];
+ salt_b [8] = salt [5];
+ salt_b [9] = salt [6];
+ salt_b [10] = salt [7];
+ salt_b [11] = '\0';
/* THREADING: Serialize access to result string of 'md5f.crypt'.
*/
TrfLock;
- res = Tcl_NewStringObj ((char*) md5f.crypt (passwd, salt_b) + 3, -1);
+ res = Tcl_NewStringObj ((char*) md5f.crypt (passwd, salt_b), -1);
TrfUnlock;
Tcl_SetObjResult (interp, res);
@@ -28,7 +28,7 @@
#include <tcl.h>
/* Encrypt at most 8 characters from KEY using salt to perturb DES. */
-extern char *crypt _ANSI_ARGS_ ((CONST char *__key, CONST char *__salt));
+extern char *crypt_md5 _ANSI_ARGS_ ((CONST char *__key, CONST char *__salt));
/* Reentrant versions of the functions above. The additional argument
@@ -70,7 +70,7 @@
/* The same here, only we call the non-reentrant version. */
char *
-crypt (key, salt)
+crypt_md5 (key, salt)
const char *key;
const char *salt;
{
|