summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-01-31 11:38:47 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-01-31 11:38:47 +0000
commitf3f375dc6b7175d4dd4ce401815e5dfdd9747083 (patch)
treefa0dff19b782e62dc641d6de987b6ec67ef37768
parenta7e67dc00ae1a9a80875f2708def6565af0c6f0e (diff)
downloadsamba-f3f375dc6b7175d4dd4ce401815e5dfdd9747083.tar.gz
Initialise some SAM_ACCOUNT structs to NULL, and add some more error checking.
Andrew Bartlett
-rw-r--r--source/utils/pdbedit.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/source/utils/pdbedit.c b/source/utils/pdbedit.c
index bdf499ae47e..2ba6de55dfb 100644
--- a/source/utils/pdbedit.c
+++ b/source/utils/pdbedit.c
@@ -131,7 +131,9 @@ static int print_user_info (char *username, BOOL verbosity, BOOL smbpwdstyle)
SAM_ACCOUNT *sam_pwent=NULL;
BOOL ret;
- pdb_init_sam(&sam_pwent);
+ if (!NT_STATUS_IS_OK(pdb_init_sam (&sam_pwent))) {
+ return -1;
+ }
ret = pdb_getsampwnam (sam_pwent, username);
@@ -283,7 +285,9 @@ static int new_machine (char *machinename)
char name[16];
char *password = NULL;
- pdb_init_sam (&sam_pwent);
+ if (!NT_STATUS_IS_OK(pdb_init_sam (&sam_pwent))) {
+ return -1;
+ }
if (machinename[strlen (machinename) -1] == '$')
machinename[strlen (machinename) -1] = '\0';
@@ -317,9 +321,11 @@ static int new_machine (char *machinename)
static int delete_user_entry (char *username)
{
- SAM_ACCOUNT *samaccount;
+ SAM_ACCOUNT *samaccount = NULL;
- pdb_init_sam(&samaccount);
+ if (!NT_STATUS_IS_OK(pdb_init_sam (&samaccount))) {
+ return -1;
+ }
if (!pdb_getsampwnam(samaccount, username)) {
fprintf (stderr, "user %s does not exist in the passdb\n", username);
@@ -336,13 +342,15 @@ static int delete_user_entry (char *username)
static int delete_machine_entry (char *machinename)
{
char name[16];
- SAM_ACCOUNT *samaccount;
+ SAM_ACCOUNT *samaccount = NULL;
safe_strcpy (name, machinename, 16);
if (name[strlen(name)] != '$')
safe_strcat (name, "$", 16);
- pdb_init_sam(&samaccount);
+ if (!NT_STATUS_IS_OK(pdb_init_sam (&samaccount))) {
+ return -1;
+ }
if (!pdb_getsampwnam(samaccount, name)) {
fprintf (stderr, "user %s does not exist in the passdb\n", name);