summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-08-18 19:43:24 +0000
committerJeremy Allison <jra@samba.org>2001-08-18 19:43:24 +0000
commita6785bac152bf03db3670f6372b37f4cd5f9fd7a (patch)
tree4ebbbe4d856e27f69df599ae904d3af5790bdfd7
parenta2ccf53229cf9400bf43b4e8128a74669a3970f7 (diff)
downloadsamba-a6785bac152bf03db3670f6372b37f4cd5f9fd7a.tar.gz
samba-a6785bac152bf03db3670f6372b37f4cd5f9fd7a.tar.xz
samba-a6785bac152bf03db3670f6372b37f4cd5f9fd7a.zip
More Realloc fixes.
Jeremy.
-rw-r--r--source/nsswitch/winbindd_user.c38
-rw-r--r--source/param/params.c18
2 files changed, 38 insertions, 18 deletions
diff --git a/source/nsswitch/winbindd_user.c b/source/nsswitch/winbindd_user.c
index 30416e76d77..3d76ec90460 100644
--- a/source/nsswitch/winbindd_user.c
+++ b/source/nsswitch/winbindd_user.c
@@ -414,10 +414,20 @@ static BOOL get_sam_user_entries(struct getent_state *ent)
&num_entries, &ctr);
if (num_entries) {
- name_list = Realloc(name_list,
+ struct getpwent_user *tnl;
+
+ tnl = (struct getpwent_user *)Realloc(name_list,
sizeof(struct getpwent_user) *
(ent->num_sam_entries +
num_entries));
+
+ if (!tnl) {
+ DEBUG(0,("get_sam_user_entries: Realloc failed.\n"));
+ if (name_list)
+ free(name_list);
+ return WINBINDD_ERROR;
+ } else
+ name_list = tnl;
}
for (i = 0; i < num_entries; i++) {
@@ -590,20 +600,20 @@ enum winbindd_result winbindd_getpwent(struct winbindd_cli_state *state)
enum winbindd_result winbindd_list_users(struct winbindd_cli_state *state)
{
- struct winbindd_domain *domain;
- SAM_DISPINFO_CTR ctr;
+ struct winbindd_domain *domain;
+ SAM_DISPINFO_CTR ctr;
SAM_DISPINFO_1 info1;
- uint32 num_entries = 0, total_entries = 0;
- char *extra_data = NULL;
+ uint32 num_entries = 0, total_entries = 0;
+ char *ted, *extra_data = NULL;
int extra_data_len = 0;
DEBUG(3, ("[%5d]: list users\n", state->pid));
- /* Enumerate over trusted domains */
+ /* Enumerate over trusted domains */
ctr.sam.info1 = &info1;
- for (domain = domain_list; domain; domain = domain->next) {
+ for (domain = domain_list; domain; domain = domain->next) {
uint32 status, start_ndx = 0;
/* Skip domains other than WINBINDD_DOMAIN environment
@@ -618,7 +628,7 @@ enum winbindd_result winbindd_list_users(struct winbindd_cli_state *state)
continue;
}
- /* Query display info */
+ /* Query display info */
do {
int i;
@@ -635,12 +645,16 @@ enum winbindd_result winbindd_list_users(struct winbindd_cli_state *state)
total_entries += num_entries;
- extra_data = Realloc(extra_data, sizeof(fstring) *
+ ted = Realloc(extra_data, sizeof(fstring) *
total_entries);
-
- if (!extra_data) {
+
+ if (!ted) {
+ DEBUG(0,("winbindd_list_users: failed to enlarge buffer!\n"));
+ if (extra_data)
+ free(extra_data);
return WINBINDD_ERROR;
- }
+ } else
+ extra_data = ted;
/* Pack user list into extra data fields */
diff --git a/source/param/params.c b/source/param/params.c
index b359b269d4e..2bc32f1c66d 100644
--- a/source/param/params.c
+++ b/source/param/params.c
@@ -252,13 +252,16 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(char *) )
/* Check that the buffer is big enough for the next character. */
if( i > (bSize - 2) )
{
- bSize += BUFR_INC;
- bufr = Realloc( bufr, bSize );
- if( NULL == bufr )
+ char *tb;
+
+ tb = Realloc( bufr, bSize +BUFR_INC );
+ if( NULL == tb )
{
DEBUG(0, ("%s Memory re-allocation failure.", func) );
return( False );
}
+ bufr = tb;
+ bSize += BUFR_INC;
}
/* Handle a single character. */
@@ -346,13 +349,16 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(char *, char *), int c )
if( i > (bSize - 2) ) /* Ensure there's space for next char. */
{
- bSize += BUFR_INC;
- bufr = Realloc( bufr, bSize );
- if( NULL == bufr )
+ char *tb;
+
+ tb = Realloc( bufr, bSize + BUFR_INC );
+ if( NULL == tb )
{
DEBUG(0, ("%s Memory re-allocation failure.", func) );
return( False );
}
+ bufr = tb;
+ bSize += BUFR_INC;
}
switch( c )