]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/passwd.c
close registry, and return static pointer (no free) from getRegParam
[openldap] / libraries / liblutil / passwd.c
index a8f69dc5ff3baea01409fbf8db9d1c8aa3fdc06a..99c5cfdc648c17e3cf31e1d4ae75aa437c5fa01a 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "portable.h"
 
-#include <stdlib.h>
+#include <ac/stdlib.h>
 
 #include <ac/string.h>
 #include <ac/unistd.h>
@@ -81,7 +81,7 @@ lutil_passwd(
                unsigned char *orig_pass = NULL;
  
                /* base64 un-encode password */
-               orig_pass = (unsigned char *)malloc(pw_len * 0.75 + 1);
+               orig_pass = (unsigned char *)malloc((size_t)(pw_len * 0.75 + 1));
                if ((rc = lutil_b64_pton(p, orig_pass, pw_len)) < 0)
                {
                        free(orig_pass);
@@ -98,7 +98,7 @@ lutil_passwd(
                lutil_SHA1Final(SHA1digest, &SHA1context);
  
                /* compare */
-               rc = strncmp((char *)orig_pass, (char *)SHA1digest, sizeof(SHA1digest));
+               rc = memcmp((char *)orig_pass, (char *)SHA1digest, sizeof(SHA1digest));
                free(orig_pass);
                return(rc);
 
@@ -111,7 +111,7 @@ lutil_passwd(
                unsigned char *orig_pass = NULL;
 
                /* base64 un-encode password */
-               orig_pass = (unsigned char *)malloc(pw_len * 0.75 + 1);
+               orig_pass = (unsigned char *)malloc((size_t)(pw_len * 0.75 + 1));
                if ((rc = lutil_b64_pton(p, orig_pass, pw_len)) < 0)
                {
                        free(orig_pass);
@@ -128,7 +128,7 @@ lutil_passwd(
                lutil_MD5Final(MD5digest, &MD5context);
 
                /* compare */
-               rc = strncmp((char *)orig_pass, (char *)MD5digest, sizeof(MD5digest));
+               rc = memcmp((char *)orig_pass, (char *)MD5digest, sizeof(MD5digest));
                free(orig_pass);
                return ( rc );