X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=contrib%2Fslapd-modules%2Fpasswd%2Fsha2%2Fslapd-sha2.c;h=544829f59eb1afb589fe9c272661e54d3e0e9381;hb=59e9ff6243465640956b58ad1756a3ede53eca7c;hp=e7cfc4ba9129b2c58a0fcb042ecc1116e241b22b;hpb=160d2b74c5315ef877a582f95a1193986a48b7bc;p=openldap diff --git a/contrib/slapd-modules/passwd/sha2/slapd-sha2.c b/contrib/slapd-modules/passwd/sha2/slapd-sha2.c index e7cfc4ba91..544829f59e 100644 --- a/contrib/slapd-modules/passwd/sha2/slapd-sha2.c +++ b/contrib/slapd-modules/passwd/sha2/slapd-sha2.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 2009-2013 The OpenLDAP Foundation. + * Copyright 2009-2018 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -230,21 +230,21 @@ static int chk_ssha256( unsigned char SHAdigest[SHA256_DIGEST_LENGTH]; int rc; unsigned char *orig_pass = NULL; + size_t decode_len = LUTIL_BASE64_DECODE_LEN(passwd->bv_len); /* safety check */ - if (LUTIL_BASE64_DECODE_LEN(passwd->bv_len) <= sizeof(SHAdigest)) { + if (decode_len <= sizeof(SHAdigest)) { return LUTIL_PASSWD_ERR; } /* base64 un-encode password */ - orig_pass = (unsigned char *) ber_memalloc( (size_t) ( - LUTIL_BASE64_DECODE_LEN(passwd->bv_len) + 1) ); + orig_pass = (unsigned char *) ber_memalloc(decode_len + 1); if( orig_pass == NULL ) return LUTIL_PASSWD_ERR; - rc = lutil_b64_pton(passwd->bv_val, orig_pass, passwd->bv_len); + rc = lutil_b64_pton(passwd->bv_val, orig_pass, decode_len); - if( rc <= sizeof(SHAdigest) ) { + if( rc <= (int)(sizeof(SHAdigest)) ) { ber_memfree(orig_pass); return LUTIL_PASSWD_ERR; } @@ -274,19 +274,19 @@ static int chk_sha256( unsigned char SHAdigest[SHA256_DIGEST_LENGTH]; int rc; unsigned char *orig_pass = NULL; + size_t decode_len = LUTIL_BASE64_DECODE_LEN(passwd->bv_len); /* safety check */ - if (LUTIL_BASE64_DECODE_LEN(passwd->bv_len) < sizeof(SHAdigest)) { + if (decode_len < sizeof(SHAdigest)) { return LUTIL_PASSWD_ERR; } /* base64 un-encode password */ - orig_pass = (unsigned char *) ber_memalloc( (size_t) ( - LUTIL_BASE64_DECODE_LEN(passwd->bv_len) + 1) ); + orig_pass = (unsigned char *) ber_memalloc(decode_len + 1); if( orig_pass == NULL ) return LUTIL_PASSWD_ERR; - rc = lutil_b64_pton(passwd->bv_val, orig_pass, passwd->bv_len); + rc = lutil_b64_pton(passwd->bv_val, orig_pass, decode_len); if( rc != sizeof(SHAdigest) ) { ber_memfree(orig_pass); @@ -318,21 +318,21 @@ static int chk_ssha384( unsigned char SHAdigest[SHA384_DIGEST_LENGTH]; int rc; unsigned char *orig_pass = NULL; + size_t decode_len = LUTIL_BASE64_DECODE_LEN(passwd->bv_len); /* safety check */ - if (LUTIL_BASE64_DECODE_LEN(passwd->bv_len) <= sizeof(SHAdigest)) { + if (decode_len <= sizeof(SHAdigest)) { return LUTIL_PASSWD_ERR; } /* base64 un-encode password */ - orig_pass = (unsigned char *) ber_memalloc( (size_t) ( - LUTIL_BASE64_DECODE_LEN(passwd->bv_len) + 1) ); + orig_pass = (unsigned char *) ber_memalloc(decode_len + 1); if( orig_pass == NULL ) return LUTIL_PASSWD_ERR; - rc = lutil_b64_pton(passwd->bv_val, orig_pass, passwd->bv_len); + rc = lutil_b64_pton(passwd->bv_val, orig_pass, decode_len); - if( rc <= sizeof(SHAdigest) ) { + if( rc <= (int)(sizeof(SHAdigest)) ) { ber_memfree(orig_pass); return LUTIL_PASSWD_ERR; } @@ -362,19 +362,19 @@ static int chk_sha384( unsigned char SHAdigest[SHA384_DIGEST_LENGTH]; int rc; unsigned char *orig_pass = NULL; + size_t decode_len = LUTIL_BASE64_DECODE_LEN(passwd->bv_len); /* safety check */ - if (LUTIL_BASE64_DECODE_LEN(passwd->bv_len) < sizeof(SHAdigest)) { + if (decode_len < sizeof(SHAdigest)) { return LUTIL_PASSWD_ERR; } /* base64 un-encode password */ - orig_pass = (unsigned char *) ber_memalloc( (size_t) ( - LUTIL_BASE64_DECODE_LEN(passwd->bv_len) + 1) ); + orig_pass = (unsigned char *) ber_memalloc(decode_len + 1); if( orig_pass == NULL ) return LUTIL_PASSWD_ERR; - rc = lutil_b64_pton(passwd->bv_val, orig_pass, passwd->bv_len); + rc = lutil_b64_pton(passwd->bv_val, orig_pass, decode_len); if( rc != sizeof(SHAdigest) ) { ber_memfree(orig_pass); @@ -406,21 +406,21 @@ static int chk_ssha512( unsigned char SHAdigest[SHA512_DIGEST_LENGTH]; int rc; unsigned char *orig_pass = NULL; + size_t decode_len = LUTIL_BASE64_DECODE_LEN(passwd->bv_len); /* safety check */ - if (LUTIL_BASE64_DECODE_LEN(passwd->bv_len) <= sizeof(SHAdigest)) { + if (decode_len <= sizeof(SHAdigest)) { return LUTIL_PASSWD_ERR; } /* base64 un-encode password */ - orig_pass = (unsigned char *) ber_memalloc( (size_t) ( - LUTIL_BASE64_DECODE_LEN(passwd->bv_len) + 1) ); + orig_pass = (unsigned char *) ber_memalloc(decode_len + 1); if( orig_pass == NULL ) return LUTIL_PASSWD_ERR; - rc = lutil_b64_pton(passwd->bv_val, orig_pass, passwd->bv_len); + rc = lutil_b64_pton(passwd->bv_val, orig_pass, decode_len); - if( rc <= sizeof(SHAdigest) ) { + if( rc <= (int)(sizeof(SHAdigest)) ) { ber_memfree(orig_pass); return LUTIL_PASSWD_ERR; } @@ -450,19 +450,19 @@ static int chk_sha512( unsigned char SHAdigest[SHA512_DIGEST_LENGTH]; int rc; unsigned char *orig_pass = NULL; + size_t decode_len = LUTIL_BASE64_DECODE_LEN(passwd->bv_len); /* safety check */ - if (LUTIL_BASE64_DECODE_LEN(passwd->bv_len) < sizeof(SHAdigest)) { + if (decode_len < sizeof(SHAdigest)) { return LUTIL_PASSWD_ERR; } /* base64 un-encode password */ - orig_pass = (unsigned char *) ber_memalloc( (size_t) ( - LUTIL_BASE64_DECODE_LEN(passwd->bv_len) + 1) ); + orig_pass = (unsigned char *) ber_memalloc(decode_len + 1); if( orig_pass == NULL ) return LUTIL_PASSWD_ERR; - rc = lutil_b64_pton(passwd->bv_val, orig_pass, passwd->bv_len); + rc = lutil_b64_pton(passwd->bv_val, orig_pass, decode_len); if( rc != sizeof(SHAdigest) ) { ber_memfree(orig_pass);