Set the method string as a constant string.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 6 Jan 2008 13:49:00 +0000 (13:49 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 6 Jan 2008 13:49:00 +0000 (13:49 +0000)
ChangeLog
lib/encrypt.c

index 0c92e18d188bc7e602dd721cc44524b6e92e3dfa..24ad6b2ec5255c89b27b397bd14e2ee1482778d7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-01-06  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * lib/encrypt.c: Set the method string as a constant string.
+
 2008-01-06  Nicolas François  <nicolas.francois@centraliens.net>
 
        * lib/port.c: Assume <errno.h> declares errno.
index eda9713fd1b998011c8b3aeabcc3a22efb8693ea..9a880e83bed13051bd093733d25265df205c265c 100644 (file)
@@ -54,7 +54,7 @@ char *pw_encrypt (const char *clear, const char *salt)
         * supported, and return a DES encrypted password. */
        if (salt && salt[0] == '$' && strlen (cp) <= 13)
        {
-               char *method = "$1$";
+               const char *method;
                switch (salt[1])
                {
                        case '1':
@@ -67,7 +67,11 @@ char *pw_encrypt (const char *clear, const char *salt)
                                method = "SHA512";
                                break;
                        default:
-                               method[1] = salt[1];
+                       {
+                               static char nummethod[4] = "$x$";
+                               nummethod[1] = salt[1];
+                               method = &nummethod[0];
+                       }
                }
                fprintf (stderr,
                         _("crypt method not supported by libcrypt? (%s)\n"),