Skip to content

Commit

Permalink
* nis/nis_call.c (rec_dirsearch): Handle __nis_finddirectory and
Browse files Browse the repository at this point in the history
	rec_dirsearch returning NULL.
	(first_shoot): Handle __nis_finddirectory returning NULL.
	(__nisfind_server): Fix leak when rec_dirsearch returns NULL.
  • Loading branch information
Ulrich Drepper committed May 18, 2006
1 parent 388c779 commit 5f1724b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
2006-05-17 Ulrich Drepper <drepper@redhat.com>

* nis/nis_call.c (rec_dirsearch): Handle __nis_finddirectory and
rec_dirsearch returning NULL.
(first_shoot): Handle __nis_finddirectory returning NULL.
(__nisfind_server): Fix leak when rec_dirsearch returns NULL.

* sysdeps/unix/sysv/linux/sys/inotify.h: Define IN_CLOSE, IN_MOVE,
IN_ONLYDIR, IN_DONT_FOLLOW, and IN_MASK_ADD.

Expand Down
37 changes: 29 additions & 8 deletions nis/nis_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, nis_error *status)
domain ! (Now I understand why a root server must be a
replica of the parent domain) */
fd_res = __nis_finddirectory (dir, ndomain);
if (fd_res == NULL)
{
*status = NIS_NOMEMORY;
return NULL;
}
*status = fd_res->status;
if (fd_res->status != NIS_SUCCESS)
{
Expand All @@ -386,7 +391,11 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, nis_error *status)
/* We have found a NIS+ server serving ndomain, now
let us search for "name" */
nis_free_directory (dir);
return rec_dirsearch (name, obj, status);
dir = rec_dirsearch (name, obj, status);
if (dir != obj)
/* This also covers the case dir == NULL. */
nis_free_directory (obj);
return dir;
}
else
{
Expand Down Expand Up @@ -433,6 +442,11 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, nis_error *status)
strcpy (cp, domain);

fd_res = __nis_finddirectory (dir, leaf);
if (fd_res == NULL)
{
*status = NIS_NOMEMORY;
return NULL;
}
*status = fd_res->status;
if (fd_res->status != NIS_SUCCESS)
{
Expand Down Expand Up @@ -484,6 +498,8 @@ first_shoot (const_nis_name name, directory_obj *dir)
return dir;

fd_res = __nis_finddirectory (dir, domain);
if (fd_res == NULL)
return NULL;
if (fd_res->status == NIS_SUCCESS
&& (obj = calloc (1, sizeof (directory_obj))) != NULL)
{
Expand Down Expand Up @@ -513,28 +529,33 @@ __nisfind_server (const_nis_name name, directory_obj **dir)
dir = __nis_cache_search (name, flags, &cinfo);
#endif

nis_error result = NIS_SUCCESS;
if (*dir == NULL)
{
nis_error status;
directory_obj *obj;

*dir = readColdStartFile ();
if (*dir == NULL) /* No /var/nis/NIS_COLD_START->no NIS+ installed */
if (*dir == NULL)
/* No /var/nis/NIS_COLD_START->no NIS+ installed. */
return NIS_UNAVAIL;

/* Try at first, if servers in "dir" know our object */
obj = first_shoot (name, *dir);
if (obj == NULL)
{
*dir = rec_dirsearch (name, *dir, &status);
if (*dir == NULL)
return status;
obj = rec_dirsearch (name, *dir, &status);
if (obj == NULL)
result = status;

if (*dir != obj)
nis_free_directory (*dir);
}
else
*dir = obj;

*dir = obj;
}

return NIS_SUCCESS;
return result;
}

nis_error
Expand Down

0 comments on commit 5f1724b

Please sign in to comment.