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
commitf3ee505fcef3baccd508281f81e6ba9b20b83be3 (patch)
tree9462a49cd76ff8b7fbc0eb6e54f5ed0647b16e29
parent359dfddcda49f03003747df4ec9a37a11bb35bad (diff)
downloadsamba-f3ee505fcef3baccd508281f81e6ba9b20b83be3.tar.gz
samba-f3ee505fcef3baccd508281f81e6ba9b20b83be3.tar.bz2
samba-f3ee505fcef3baccd508281f81e6ba9b20b83be3.zip
Initialise some SAM_ACCOUNT structs to NULL, and add some more error checking.
Andrew Bartlett (This used to be commit f3f375dc6b7175d4dd4ce401815e5dfdd9747083)
-rw-r--r--source3/utils/pdbedit.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index bdf499ae47..2ba6de55df 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/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);