Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
1999-05-16  Thorsten Kukuk  <[email protected]>

	* sunrpc/etc.rpc: Add portmapper, rstat_svc and pcnfs.
	* sunrpc/key_call.c: Fix memory leak, close file handle.
	* nis/nis_creategroup.c: Use malloc instead of calloc,
	set ctime and mtime.
	* nis/nis_subr.c: Check for realloc result.
	* nis/nis_file.c: Fix memory leak.
	* nis/nis_table.c: Pretty print.
	* nis/nis_getservlist.c: Likewise.
	* nis/nis_ismember.c: Likewise.
	* nis/nis_lookup.c: Likewise.
	* nis/nis_ping.c: Likewise.
	* nis/nis_removemember.c: Likewise.
	* nis/nis_util.c: Likewise, check calloc result.
  • Loading branch information
Ulrich Drepper committed May 16, 1999
1 parent 7d853c9 commit 32abdb7
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 102 deletions.
16 changes: 16 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
1999-05-16 Thorsten Kukuk <[email protected]>

* sunrpc/etc.rpc: Add portmapper, rstat_svc and pcnfs.
* sunrpc/key_call.c: Fix memory leak, close file handle.
* nis/nis_creategroup.c: Use malloc instead of calloc,
set ctime and mtime.
* nis/nis_subr.c: Check for realloc result.
* nis/nis_file.c: Fix memory leak.
* nis/nis_table.c: Pretty print.
* nis/nis_getservlist.c: Likewise.
* nis/nis_ismember.c: Likewise.
* nis/nis_lookup.c: Likewise.
* nis/nis_ping.c: Likewise.
* nis/nis_removemember.c: Likewise.
* nis/nis_util.c: Likewise, check calloc result.

1999-05-16 Roland McGrath <[email protected]>

* sysdeps/unix/sysv/linux/sys/socketvar.h: Moved to ...
Expand Down
14 changes: 9 additions & 5 deletions nis/nis_file.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
Expand Down Expand Up @@ -82,15 +82,19 @@ nis_read_obj (const char *name)
XDR xdrs;
FILE *in;
bool_t status;
nis_object *obj = calloc (1, sizeof (nis_object));

if (obj == NULL)
return NULL;
nis_object *obj;

in = fopen (name, "rb");
if (in == NULL)
return NULL;

obj = calloc (1, sizeof (nis_object));
if (obj == NULL)
{
fclose (in);
return NULL;
}

xdrstdio_create (&xdrs, in, XDR_DECODE);
status =_xdr_nis_object (&xdrs, obj);
xdr_destroy (&xdrs);
Expand Down
15 changes: 11 additions & 4 deletions nis/nis_getservlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ nis_getservlist (const_nis_name dir)

res = nis_lookup (dir, FOLLOW_LINKS);

if (NIS_RES_STATUS (res) == NIS_SUCCESS)
if (res != NULL && NIS_RES_STATUS (res) == NIS_SUCCESS)
{
unsigned long i;
nis_server *server;
Expand All @@ -41,14 +41,19 @@ nis_getservlist (const_nis_name dir)
(NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len + 1));
if (serv == NULL)
return NULL;

for (i = 0; i < NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len;
++i)
{
server =
&NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_val[i];
serv[i] = calloc (1, sizeof (nis_server));
if (server->name != NULL)
serv[i]->name = strdup (server->name);
{
serv[i]->name = strdup (server->name);
if (serv[i]->name == NULL)
return NULL;
}

serv[i]->ep.ep_len = server->ep.ep_len;
if (serv[i]->ep.ep_len > 0)
Expand Down Expand Up @@ -96,15 +101,17 @@ nis_getservlist (const_nis_name dir)
serv[i]->pkey.n_bytes = NULL;
}
serv[i] = NULL;

nis_freeresult (res);
}
else
{
serv = malloc (sizeof (nis_server *));
if (serv != NULL)
serv[0] = NULL;
}

if (res != NULL)
nis_freeresult (res);

return serv;
}

Expand Down
51 changes: 38 additions & 13 deletions nis/nis_ismember.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
/* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
Expand Down Expand Up @@ -43,13 +43,21 @@ internal_ismember (const_nis_name principal, const_nis_name group)
*cp++ = '.';
strcpy (cp, cp2);
}

res = nis_lookup (buf, EXPAND_NAME|FOLLOW_LINKS);
if (NIS_RES_STATUS (res) != NIS_SUCCESS)
return 0;
if (res == NULL || NIS_RES_STATUS (res) != NIS_SUCCESS)
{
if (res)
nis_freeresult (res);
return 0;
}

if ((NIS_RES_NUMOBJ (res) != 1) ||
(__type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ))
return 0;
{
nis_freeresult (res);
return 0;
}

/* We search twice in the list, at first, if we have the name
with a "-", then if without. "-member" has priority */
Expand All @@ -59,14 +67,19 @@ internal_ismember (const_nis_name principal, const_nis_name group)
if (cp[0] == '-')
{
if (strcmp (&cp[1], principal) == 0)
return -1;
{
nis_freeresult (res);
return -1;
}
if (cp[1] == '@')
switch (internal_ismember (principal, &cp[2]))
{
case -1:
nis_freeresult (res);
return -1;
case 1:
return -1;
nis_freeresult (res);
return 1;
default:
break;
}
Expand All @@ -76,26 +89,34 @@ internal_ismember (const_nis_name principal, const_nis_name group)
char buf1[strlen (principal) + 2];
char buf2[strlen (cp) + 2];

strcpy (buf1, nis_domain_of (principal));
strcpy (buf2, nis_domain_of (cp));
if (strcmp (buf1, buf2) == 0)
return -1;
if (strcmp (nis_domain_of_r (principal, buf1, sizeof buf1),
nis_domain_of_r (cp, buf2, sizeof buf2)) == 0)
{
nis_freeresult (res);
return -1;
}
}
}
}

for (i = 0; i < NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len; ++i)
{
cp = NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val[i];
if (cp[0] != '-')
{
if (strcmp (cp, principal) == 0)
return 1;
{
nis_freeresult (res);
return 1;
}
if (cp[0] == '@')
switch (internal_ismember (principal, &cp[1]))
{
case -1:
nis_freeresult (res);
return -1;
case 1:
nis_freeresult (res);
return 1;
default:
break;
Expand All @@ -108,10 +129,14 @@ internal_ismember (const_nis_name principal, const_nis_name group)

if (strcmp (nis_domain_of_r (principal, buf1, sizeof buf1),
nis_domain_of_r (cp, buf2, sizeof buf2)) == 0)
return 1;
{
nis_freeresult (res);
return 1;
}
}
}
}
nis_freeresult (res);
return 0;
}

Expand Down
10 changes: 5 additions & 5 deletions nis/nis_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ nis_lookup (const_nis_name name, const unsigned int flags)
++count_links;
req.ns_name =
strdup (NIS_RES_OBJECT (res)->LI_data.li_name);
if (req.ns_name == NULL)
return NULL;

nis_freeresult (res);
res = calloc (1, sizeof (nis_result));
if (res == NULL)
{
__nisbind_destroy (&bptr);
nis_free_directory (dir);
return NULL;
}
return NULL;

link_first_try = 1; /* Try at first the old binding */
goto again;
}
Expand Down
12 changes: 8 additions & 4 deletions nis/nis_ping.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
/* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
Expand Down Expand Up @@ -37,8 +37,12 @@ nis_ping (const_nis_name dirname, unsigned int utime,
if (dirobj == NULL)
{
res = nis_lookup (dirname, MASTER_ONLY);
if (NIS_RES_STATUS (res) != NIS_SUCCESS)
return;
if (res == NULL || NIS_RES_STATUS (res) != NIS_SUCCESS)
{
if (res)
nis_freeresult (res);
return;
}
obj = res->objects.objects_val;
}
else
Expand Down
22 changes: 16 additions & 6 deletions nis/nis_removemember.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
/* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <[email protected]>, 1997.
Expand Down Expand Up @@ -44,22 +44,31 @@ nis_removemember (const_nis_name member, const_nis_name group)
stpcpy (cp, cp2);
}
res = nis_lookup (buf, FOLLOW_LINKS|EXPAND_NAME);
if (NIS_RES_STATUS (res) != NIS_SUCCESS)
if (res == NULL || NIS_RES_STATUS (res) != NIS_SUCCESS)
{
status = NIS_RES_STATUS (res);
nis_freeresult (res);
if (res)
{
status = NIS_RES_STATUS (res);
nis_freeresult (res);
}
else
return NIS_NOMEMORY;
return status;
}

if ((res->objects.objects_len != 1) ||
(__type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ))
return NIS_INVALIDOBJ;
{
nis_freeresult (res);
return NIS_INVALIDOBJ;
}

newmem =
calloc (1, NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_len *
calloc (NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_len,
sizeof (char *));
if (newmem == NULL)
return NIS_NOMEMORY;

k = NIS_RES_OBJECT (res)[0].GR_data.gr_members.gr_members_len;
j = 0;
for (i = 0; i < NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_len;
Expand All @@ -81,6 +90,7 @@ nis_removemember (const_nis_name member, const_nis_name group)
newmem = realloc (newmem, k * sizeof (char*));
if (newmem == NULL)
return NIS_NOMEMORY;

NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val = newmem;
NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len = k;

Expand Down
Loading

0 comments on commit 32abdb7

Please sign in to comment.