[PATCH] Use "all_zero()"

Ralph Böhme slow at samba.org
Tue Jan 3 11:15:43 UTC 2017


Hi!

I've double checked all memcmp->all_zero replacements and found one that
inverted the logic:

On Mon, Jan 02, 2017 at 03:37:43PM +0100, Volker Lendecke wrote:
> From e978691c41697ccf6a4990dec8fae802ccb575ce Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sat, 31 Dec 2016 12:45:51 +0000
> Subject: [PATCH 11/22] auth: Use "all_zero" where appropriate
> 
> ... Saves a few bytes of footprint
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  source3/auth/check_samsec.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/source3/auth/check_samsec.c b/source3/auth/check_samsec.c
> index cbcde08..7347ed1 100644
> --- a/source3/auth/check_samsec.c
> +++ b/source3/auth/check_samsec.c
> @@ -322,7 +322,6 @@ static bool need_to_increment_bad_pw_count(
>  	username = pdb_get_username(sampass);
>  
>  	for (i=1; i < MIN(MIN(3, policy_pwhistory_len), pwhistory_len); i++) {
> -		static const uint8_t zero16[SALTED_MD5_HASH_LEN];
>  		const uint8_t *salt;
>  		const uint8_t *nt_pw;
>  		NTSTATUS status;
> @@ -332,12 +331,12 @@ static bool need_to_increment_bad_pw_count(
>  		salt = &pwhistory[i*PW_HISTORY_ENTRY_LEN];
>  		nt_pw = salt + PW_HISTORY_SALT_LEN;
>  
> -		if (memcmp(zero16, nt_pw, NT_HASH_LEN) == 0) {
> +		if (!all_zero(nt_pw, NT_HASH_LEN)) {
>  			/* skip zero password hash */
>  			continue;
>  		}

I've fixed it to be

> -		if (memcmp(zero16, nt_pw, NT_HASH_LEN) == 0) {
> +		if (all_zero(nt_pw, NT_HASH_LEN)) {

and pushed the whole patchset with my rb.

Cheerio!
-slow



More information about the samba-technical mailing list