1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-08 04:58:40 +03:00

libnet: Use "all_zero" where appropriate

... Saves a few bytes of footprint

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Volker Lendecke 2016-12-31 12:45:51 +00:00 committed by Ralph Boehme
parent f5847b6e34
commit 20c56e21ca
6 changed files with 9 additions and 21 deletions

View File

@ -1105,7 +1105,6 @@ static NTSTATUS sam_account_from_object(struct samu *account,
TALLOC_CTX *mem_ctx = account;
const char *old_string, *new_string;
time_t unix_time, stored_time;
uchar zero_buf[16];
NTSTATUS status;
NTTIME lastLogon;
@ -1134,8 +1133,6 @@ static NTSTATUS sam_account_from_object(struct samu *account,
uint32_t acct_flags;
uint32_t units_per_week;
memset(zero_buf, '\0', sizeof(zero_buf));
objectSid = cur->object.identifier->sid;
GET_STRING_EX(sAMAccountName, true);
DEBUG(0,("sam_account_from_object(%s, %s) start\n",
@ -1329,11 +1326,11 @@ static NTSTATUS sam_account_from_object(struct samu *account,
think this channel is secure enough - don't set the passwords at all
in that case
*/
if (dBCSPwd.length == 16 && memcmp(dBCSPwd.data, zero_buf, 16) != 0) {
if (dBCSPwd.length == 16 && !all_zero(dBCSPwd.data, 16)) {
pdb_set_lanman_passwd(account, dBCSPwd.data, PDB_CHANGED);
}
if (unicodePwd.length == 16 && memcmp(unicodePwd.data, zero_buf, 16) != 0) {
if (unicodePwd.length == 16 && !all_zero(unicodePwd.data, 16)) {
pdb_set_nt_passwd(account, unicodePwd.data, PDB_CHANGED);
}

View File

@ -35,7 +35,6 @@ struct libnet_keytab_context {
const char *keytab_name;
struct ads_struct *ads;
const char *dns_domain_name;
uint8_t zero_buf[16];
uint32_t count;
struct libnet_keytab_entry *entries;
bool clean_old_entries;

View File

@ -60,19 +60,17 @@ static void display_account_info(uint32_t rid,
struct netr_DELTA_USER *r)
{
fstring hex_nt_passwd, hex_lm_passwd;
uchar zero_buf[16];
memset(zero_buf, '\0', sizeof(zero_buf));
/* Decode hashes from password hash (if they are not NULL) */
if (memcmp(r->lmpassword.hash, zero_buf, 16) != 0) {
if (!all_zero(r->lmpassword.hash, 16)) {
pdb_sethexpwd(hex_lm_passwd, r->lmpassword.hash, r->acct_flags);
} else {
pdb_sethexpwd(hex_lm_passwd, NULL, 0);
}
if (memcmp(r->ntpassword.hash, zero_buf, 16) != 0) {
if (!all_zero(r->ntpassword.hash, 16)) {
pdb_sethexpwd(hex_nt_passwd, r->ntpassword.hash, r->acct_flags);
} else {
pdb_sethexpwd(hex_nt_passwd, NULL, 0);

View File

@ -76,7 +76,7 @@ static NTSTATUS fetch_sam_entry_keytab(TALLOC_CTX *mem_ctx,
uint32_t kvno = 0;
DATA_BLOB blob;
if (memcmp(r->ntpassword.hash, ctx->zero_buf, 16) == 0) {
if (all_zero(r->ntpassword.hash, 16)) {
return NT_STATUS_OK;
}

View File

@ -652,13 +652,10 @@ static NTSTATUS fetch_account_info_to_ldif(TALLOC_CTX *mem_ctx,
char *flags, *user_rdn;
const char *ou;
const char* nopasswd = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
uchar zero_buf[16];
uint32_t rid = 0, group_rid = 0, gidNumber = 0;
time_t unix_time;
int i, ret;
memset(zero_buf, '\0', sizeof(zero_buf));
/* Get the username */
fstrcpy(username, r->account_name.string);
@ -703,12 +700,12 @@ static NTSTATUS fetch_account_info_to_ldif(TALLOC_CTX *mem_ctx,
fstrcpy(profilepath, r->profile_path.string);
/* Get lm and nt password data */
if (memcmp(r->lmpassword.hash, zero_buf, 16) != 0) {
if (!all_zero(r->lmpassword.hash, 16)) {
pdb_sethexpwd(hex_lm_passwd, r->lmpassword.hash, r->acct_flags);
} else {
pdb_sethexpwd(hex_lm_passwd, NULL, 0);
}
if (memcmp(r->ntpassword.hash, zero_buf, 16) != 0) {
if (!all_zero(r->ntpassword.hash, 16)) {
pdb_sethexpwd(hex_nt_passwd, r->ntpassword.hash, r->acct_flags);
} else {
pdb_sethexpwd(hex_nt_passwd, NULL, 0);

View File

@ -47,9 +47,6 @@ static NTSTATUS sam_account_from_delta(struct samu *account,
{
const char *old_string, *new_string;
time_t unix_time, stored_time;
uchar zero_buf[16];
memset(zero_buf, '\0', sizeof(zero_buf));
/* Username, fullname, home dir, dir drive, logon script, acct
desc, workstations, profile. */
@ -217,11 +214,11 @@ static NTSTATUS sam_account_from_delta(struct samu *account,
think this channel is secure enough - don't set the passwords at all
in that case
*/
if (memcmp(r->lmpassword.hash, zero_buf, 16) != 0) {
if (!all_zero(r->lmpassword.hash, 16)) {
pdb_set_lanman_passwd(account, r->lmpassword.hash, PDB_CHANGED);
}
if (memcmp(r->ntpassword.hash, zero_buf, 16) != 0) {
if (!all_zero(r->ntpassword.hash, 16)) {
pdb_set_nt_passwd(account, r->ntpassword.hash, PDB_CHANGED);
}