From 32334bc6553c25b706e60a321f9c16f8931f94c1 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 18 Mar 2002 23:57:14 +0000 Subject: more verbose checking in talloc and util_pw fixed tdbsam memory corruption (and segfault) reducing calls to pdb_uid_to_user_rid and countrary to 0 to move to a non alghoritmic rid allocation with some passdb modules. (This used to be commit 9836af7cd623357feaec07bc49cfb78f0aa01fc3) --- source3/utils/pdbedit.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'source3/utils/pdbedit.c') diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 2ba6de55df..71abcc74ee 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -155,27 +155,28 @@ static int print_user_info (char *username, BOOL verbosity, BOOL smbpwdstyle) static int print_users_list (BOOL verbosity, BOOL smbpwdstyle) { SAM_ACCOUNT *sam_pwent=NULL; - BOOL ret; + BOOL check, ret; - pdb_init_sam(&sam_pwent); errno = 0; /* testing --simo */ - ret = pdb_setsampwent(False); - if (ret && errno == ENOENT) { + check = pdb_setsampwent(False); + if (check && errno == ENOENT) { fprintf (stderr,"Password database not found!\n"); exit(1); } - pdb_free_sam(&sam_pwent); - while ((NT_STATUS_IS_OK(pdb_init_sam(&sam_pwent)) - && (ret = pdb_getsampwent (sam_pwent)))) { + check = True; + if (!(NT_STATUS_IS_OK(pdb_init_sam(&sam_pwent)))) return 1; + + while (check && (ret = pdb_getsampwent (sam_pwent))) { if (verbosity) printf ("---------------\n"); print_sam_info (sam_pwent, verbosity, smbpwdstyle); pdb_free_sam(&sam_pwent); + check = NT_STATUS_IS_OK(pdb_init_sam(&sam_pwent)); } - pdb_free_sam(&sam_pwent); + if (check) pdb_free_sam(&sam_pwent); - pdb_endsampwent (); + pdb_endsampwent(); return 0; } -- cgit