summaryrefslogtreecommitdiff
path: root/source3/utils/pdbedit.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-03-18 11:22:52 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-03-18 11:22:52 +0000
commitd5ee9b2f480ddbda0b8f69409698d27c99384f9c (patch)
tree2664e91ce8bbfedeaf34292fca1d5dcfb8039176 /source3/utils/pdbedit.c
parent5452ecebc7d89fac6e1047b92b77be47fe85914c (diff)
downloadsamba-d5ee9b2f480ddbda0b8f69409698d27c99384f9c.tar.gz
samba-d5ee9b2f480ddbda0b8f69409698d27c99384f9c.tar.bz2
samba-d5ee9b2f480ddbda0b8f69409698d27c99384f9c.zip
Jeremy merged across my string parinoia fixes, but forgot to enable them! :-)
This patch catches up on the rest of the work - as much string checking as is possible is done at compile time, and the rest at runtime. Lots of code converted to pstrcpy() etc, and other code reworked to correctly call sizeof(). Andrew Bartlett (This used to be commit c5b604e2ee67d74241ae2fa07ae904647d35a2be)
Diffstat (limited to 'source3/utils/pdbedit.c')
-rw-r--r--source3/utils/pdbedit.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index 9df10c21a4..265bda1e5d 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -363,20 +363,21 @@ static int new_machine (struct pdb_context *in, const char *machine_in)
{
SAM_ACCOUNT *sam_pwent=NULL;
fstring machinename;
+ fstring machineaccount;
struct passwd *pwd = NULL;
- char name[16];
fstrcpy(machinename, machine_in);
+ machinename[15]= '\0';
if (machinename[strlen (machinename) -1] == '$')
machinename[strlen (machinename) -1] = '\0';
strlower_m(machinename);
- safe_strcpy (name, machinename, 16);
- safe_strcat (name, "$", 16);
+ fstrcpy(machineaccount, machinename);
+ fstrcat(machineaccount, "$");
- if ((pwd = getpwnam_alloc(name))) {
+ if ((pwd = getpwnam_alloc(machineaccount))) {
if (!NT_STATUS_IS_OK(pdb_init_sam_pw( &sam_pwent, pwd))) {
fprintf(stderr, "Could not init sam from pw\n");
passwd_free(&pwd);
@@ -392,14 +393,14 @@ static int new_machine (struct pdb_context *in, const char *machine_in)
pdb_set_plaintext_passwd (sam_pwent, machinename);
- pdb_set_username (sam_pwent, name, PDB_CHANGED);
+ pdb_set_username (sam_pwent, machineaccount, PDB_CHANGED);
pdb_set_acct_ctrl (sam_pwent, ACB_WSTRUST, PDB_CHANGED);
pdb_set_group_sid_from_rid(sam_pwent, DOMAIN_GROUP_RID_COMPUTERS, PDB_CHANGED);
if (NT_STATUS_IS_OK(in->pdb_add_sam_account (in, sam_pwent))) {
- print_user_info (in, name, True, False);
+ print_user_info (in, machineaccount, True, False);
} else {
fprintf (stderr, "Unable to add machine! (does it already exist?)\n");
pdb_free_sam (&sam_pwent);
@@ -435,12 +436,13 @@ static int delete_user_entry (struct pdb_context *in, const char *username)
static int delete_machine_entry (struct pdb_context *in, const char *machinename)
{
- char name[16];
+ fstring name;
SAM_ACCOUNT *samaccount = NULL;
- safe_strcpy (name, machinename, 16);
- if (name[strlen(name)] != '$')
- safe_strcat (name, "$", 16);
+ fstrcpy(name, machinename);
+ name[15] = '\0';
+ if (name[strlen(name)-1] != '$')
+ fstrcat (name, "$");
if (!NT_STATUS_IS_OK(pdb_init_sam (&samaccount))) {
return -1;