else
memset(mountpassword, 0, 64);
+ if (mountpassword == NULL) {
+ printf("malloc failed\n");
+ exit(1);
+ }
+
if(filename != NULL) {
file_descript = open(filename, O_RDONLY);
if(file_descript < 0) {
fullpath[consumed/2] = '\0';
dos_clean_name( fullpath );
- ppath = strchr_m( fullpath, '\\' );
- ppath = strchr_m( ppath+1, '\\' );
- ppath = strchr_m( ppath+1, '\\' );
+ if ((ppath = strchr_m( fullpath, '\\' )) == NULL)
+ return False;
+ if ((ppath = strchr_m( ppath+1, '\\' )) == NULL)
+ return False;
+ if ((ppath = strchr_m( ppath+1, '\\' )) == NULL)
+ return False;
ppath++;
pstr_sprintf( newmount, "%s\\%s", mountpt, ppath );
int flags)
{
SMBCFILE * file = find_fd(fd);
+ if (file == NULL) {
+ errno = EBADF;
+ return -1;
+ }
return statcont->setxattr(statcont, file->fname,
name, value, size, flags);
}
size_t size)
{
SMBCFILE * file = find_fd(fd);
+ if (file == NULL) {
+ errno = EBADF;
+ return -1;
+ }
return statcont->getxattr(statcont, file->fname, name, value, size);
}
const char *name)
{
SMBCFILE * file = find_fd(fd);
+ if (file == NULL) {
+ errno = EBADF;
+ return -1;
+ }
return statcont->removexattr(statcont, file->fname, name);
}
size_t size)
{
SMBCFILE * file = find_fd(fd);
+ if (file == NULL) {
+ errno = EBADF;
+ return -1;
+ }
return statcont->listxattr(statcont, file->fname, list, size);
}
return True;
}
- aces = SMB_CALLOC_ARRAY(SEC_ACE, 1+(*the_acl)->num_aces);
+ if ((aces = SMB_CALLOC_ARRAY(SEC_ACE, 1+(*the_acl)->num_aces)) == NULL) {
+ return False;
+ }
memcpy(aces, (*the_acl)->ace, (*the_acl)->num_aces * sizeof(SEC_ACE));
memcpy(aces+(*the_acl)->num_aces, ace, sizeof(SEC_ACE));
newacl = make_sec_acl(ctx, (*the_acl)->revision,
if (!login_cache_init())
return NULL;
+ if (pdb_get_nt_username(sampass) == NULL) {
+ return NULL;
+ }
+
keybuf.dptr = SMB_STRDUP(pdb_get_nt_username(sampass));
if (!keybuf.dptr || !strlen(keybuf.dptr)) {
SAFE_FREE(keybuf.dptr);
if (!login_cache_init())
return False;
+ if (pdb_get_nt_username(sampass) == NULL) {
+ return False;
+ }
+
keybuf.dptr = SMB_STRDUP(pdb_get_nt_username(sampass));
if (!keybuf.dptr || !strlen(keybuf.dptr)) {
SAFE_FREE(keybuf.dptr);
if (!login_cache_init())
return False;
+ if (pdb_get_nt_username(sampass) == NULL) {
+ return False;
+ }
+
keybuf.dptr = SMB_STRDUP(pdb_get_nt_username(sampass));
if (!keybuf.dptr || !strlen(keybuf.dptr)) {
SAFE_FREE(keybuf.dptr);
goto done;
}
- names = TALLOC_ARRAY(mem_ctx, const char *, num_names);
+ if ((names = TALLOC_ARRAY(mem_ctx, const char *, num_names)) == NULL) {
+ result = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
names[0] = old_name;
result = rpccli_samr_lookup_names(pipe_hnd, mem_ctx, &domain_pol,
flags, num_names, names,
/* Look up rids */
if (num_rids) {
- rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids);
+ if ((rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids)) == NULL) {
+ result = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
for (i = 0; i < num_rids; i++)
rids[i] = user_gids[i].g_rid;
const char **argv)
{
WERROR result;
- char *sharename=talloc_strdup(mem_ctx, argv[0]);
+ char *sharename;
char *path;
uint32 type = STYPE_DISKTREE; /* only allow disk shares to be added */
uint32 num_users=0, perms=0;
char *password=NULL; /* don't allow a share password */
uint32 level = 2;
+ if ((sharename = talloc_strdup(mem_ctx, argv[0])) == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
path = strchr(sharename, '=');
if (!path)
return NT_STATUS_UNSUCCESSFUL;
SRV_SHARE_INFO_1 *info1;
ctr->share.info1 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_1, 1);
+ if (ctr->share.info1 == NULL) {
+ result = WERR_NOMEM;
+ goto done;
+ }
info1 = ctr->share.info1;
memset(ctr->share.info1, 0, sizeof(SRV_SHARE_INFO_1));
SRV_SHARE_INFO_2 *info2;
ctr->share.info2 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_2, 1);
+ if (ctr->share.info2 == NULL) {
+ result = WERR_NOMEM;
+ goto done;
+ }
info2 = ctr->share.info2;
memset(ctr->share.info2, 0, sizeof(SRV_SHARE_INFO_2));
SRV_SHARE_INFO_502 *info502;
ctr->share.info502 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_502, 1);
+ if (ctr->share.info502 == NULL) {
+ result = WERR_NOMEM;
+ goto done;
+ }
info502 = ctr->share.info502;
memset(ctr->share.info502, 0, sizeof(SRV_SHARE_INFO_502));
strupper_m(acct_name);
- names = TALLOC_ARRAY(mem_ctx, const char *, 1);
+ if ((names = TALLOC_ARRAY(mem_ctx, const char *, 1)) == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
names[0] = acct_name;
fstring padding;
int pad_len, col_len = 30;
+ if (policy == NULL) {
+ policy = "Unknown";
+ }
+ if (value == NULL) {
+ value = "Invalid";
+ }
+
/* calculate padding space for d_printf to look nicer */
pad_len = col_len - strlen(policy);
padding[pad_len] = 0;
"could not open domain");
/* Create domain user */
- acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname());
+ if ((acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname())) == NULL) {
+ result = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
strlower_m(acct_name);
const_acct_name = acct_name;
/* get the root of the registry file */
- nk = regfio_rootkey( registry );
+ if ((nk = regfio_rootkey( registry )) == NULL) {
+ d_fprintf(stderr, "Could not get rootkey\n");
+ return 1;
+ }
d_printf("[%s]\n", nk->keyname);
dump_values( nk );
d_printf("\n");
/* get the root of the registry file */
- nk = regfio_rootkey( infile );
+ if ((nk = regfio_rootkey( infile )) == NULL) {
+ d_fprintf(stderr, "Could not get rootkey\n");
+ goto out_close_infile;
+ }
d_printf("RootKey: [%s]\n", nk->keyname);
write_registry_tree( infile, nk, NULL, outfile, "" );
}
}
+ if (pdb_get_group_sid(sam_account) == NULL) {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
group_sid = *pdb_get_group_sid(sam_account);
if (!pdb_getgrsid(&map, group_sid)) {
return NT_STATUS_NO_MEMORY;
}
- nt_members = TALLOC_ZERO_ARRAY(t, char *, delta->num_members);
+ if ((nt_members = TALLOC_ZERO_ARRAY(t, char *, delta->num_members)) == NULL) {
+ DEBUG(0, ("talloc failed\n"));
+ talloc_free(t);
+ return NT_STATUS_NO_MEMORY;
+ }
for (i=0; i<delta->num_members; i++) {
struct samu *member = NULL;
return -1;
}
- ldap_bk = talloc_strdup(tc, lp_passdb_backend());
+ if ((ldap_bk = talloc_strdup(tc, lp_passdb_backend())) == NULL) {
+ d_fprintf(stderr, "talloc failed\n");
+ talloc_free(tc);
+ return -1;
+ }
p = strchr(ldap_bk, ':');
if (p) {
*p = 0;
d_fprintf(stderr, "Can't create Guest user, Domain Users group not available!\n");
goto done;
}
- pwd = talloc(tc, struct passwd);
+ if ((pwd = talloc(tc, struct passwd)) == NULL) {
+ d_fprintf(stderr, "talloc failed\n");
+ goto done;
+ }
pwd->pw_name = talloc_strdup(pwd, lp_guestaccount());
if (!winbind_allocate_uid(&(pwd->pw_uid))) {
d_fprintf(stderr, "Unable to allocate a new uid to create the Guest user!\n");
return net_usershare_delete_usage(argc, argv);
}
- sharename = strdup_lower(argv[0]);
+ if ((sharename = strdup_lower(argv[0])) == NULL) {
+ d_fprintf(stderr, "strdup failed\n");
+ return -1;
+ }
if (!validate_net_name(sharename, INVALID_SHARENAME_CHARS, strlen(sharename))) {
d_fprintf(stderr, "net usershare delete: share name %s contains "
}
/* Get the name */
- name = talloc_strndup(ctx, pacl, pcolon - pacl);
+ if ((name = talloc_strndup(ctx, pacl, pcolon - pacl)) == NULL) {
+ d_fprintf(stderr, "talloc_strndup failed\n");
+ talloc_destroy(ctx);
+ SAFE_FREE(sharename);
+ return -1;
+ }
if (!string_to_sid(&sid, name)) {
/* Convert to a SID */
NTSTATUS ntstatus = net_lookup_sid_from_name(ctx, name, &sid);