summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Youngman <jay@gnu.org>2015-05-09 23:15:02 +0100
committerJames Youngman <jay@gnu.org>2015-05-09 23:15:02 +0100
commit8b8f40e39d0810f7e658cb23e4c431a55409495e (patch)
treee9f4f77bfa4333f7fa32d45bcde2076972e86fad
parent31ef19a3b0a98e53d952625ee44a47ede5625fa3 (diff)
downloadfindutils-8b8f40e39d0810f7e658cb23e4c431a55409495e.tar.gz
Fix Savannah bug #45062: Enabling CACHE_IDS causes segfaults
* configure.ac: Modify the --enable-id-cache option such that it no longer has any effect, since that code causes segfaults. * NEWS: Mention this bugfix. * find/parser.c (parse_nogroup): Remove CACHE_IDS code. (parse_nouser): Likewise. (parse_version): Indicate that CACHE_IDS is ignored. * find/pred.c (pred_nogroup): Remove CACHE_IDS code. (pred_nouser): Likewise.
-rw-r--r--NEWS7
-rw-r--r--configure.ac7
-rw-r--r--find/parser.c66
-rw-r--r--find/pred.c16
4 files changed, 9 insertions, 87 deletions
diff --git a/NEWS b/NEWS
index 1577b844..520cf43d 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,13 @@ GNU findutils NEWS - User visible changes. -*- outline -*- (allout)
* Major changes in release 4.5.15-git, 2014-MM-DD
+** Bug Fixes
+
+#45062: Enabling CACHE_IDS causes segfaults (this bug affects many
+ historic releases, probably since release 3.0 in 1991). You
+ would not have been affected by this problem unless you used
+ the option --enable-id-cache when invoking confgure.
+
* Major changes in release 4.5.14, 2014-07-19
** Bug Fixes
diff --git a/configure.ac b/configure.ac
index 498ee0fd..eceaf89a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,12 +16,7 @@ dnl check for --with-fts
FIND_WITH_FTS
AC_ARG_ENABLE(id-cache,
-[ --enable-id-cache cache all UIDs & GIDs; avoid if using NIS or Hesiod],
- AC_DEFINE([CACHE_IDS], 1, [Define if you want find -nouser and -nogroup to make tables of
- used UIDs and GIDs at startup instead of using getpwuid or
- getgrgid when needed. Speeds up -nouser and -nogroup unless you
- are running NIS or Hesiod, which make password and group calls
- very expensive.]))
+[ --enable-id-cache This currently has no effect.],)
AC_ARG_ENABLE(debug,
AS_HELP_STRING(--enable-debug,Enable debugging output which is likely to be interesting to people debugging findutils),
diff --git a/find/parser.c b/find/parser.c
index dc6c47c6..0d19ba3c 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -1708,22 +1708,6 @@ parse_noleaf (const struct parser_table* entry, char **argv, int *arg_ptr)
return parse_noop (entry, argv, arg_ptr);
}
-#ifdef CACHE_IDS
-/* Arbitrary amount by which to increase size
- of `uid_unused' and `gid_unused'. */
-#define ALLOC_STEP 2048
-
-/* Boolean: if uid_unused[n] is nonzero, then UID n has no passwd entry. */
-char *uid_unused = NULL;
-
-/* Number of elements in `uid_unused'. */
-unsigned uid_allocated;
-
-/* Similar for GIDs and group entries. */
-char *gid_unused = NULL;
-unsigned gid_allocated;
-#endif
-
static bool
parse_nogroup (const struct parser_table* entry, char **argv, int *arg_ptr)
{
@@ -1734,30 +1718,6 @@ parse_nogroup (const struct parser_table* entry, char **argv, int *arg_ptr)
our_pred = insert_primary (entry, NULL);
our_pred->est_success_rate = 1e-4;
-#ifdef CACHE_IDS
- if (gid_unused == NULL)
- {
- struct group *gr;
-
- gid_allocated = ALLOC_STEP;
- gid_unused = xmalloc (gid_allocated);
- memset (gid_unused, 1, gid_allocated);
- setgrent ();
- while ((gr = getgrent ()) != NULL)
- {
- if ((unsigned) gr->gr_gid >= gid_allocated)
- {
- unsigned new_allocated = (unsigned) gr->gr_gid + ALLOC_STEP;
- gid_unused = xrealloc (gid_unused, new_allocated);
- memset (gid_unused + gid_allocated, 1,
- new_allocated - gid_allocated);
- gid_allocated = new_allocated;
- }
- gid_unused[(unsigned) gr->gr_gid] = 0;
- }
- endgrent ();
- }
-#endif
return true;
}
@@ -1771,30 +1731,6 @@ parse_nouser (const struct parser_table* entry, char **argv, int *arg_ptr)
our_pred = insert_primary_noarg (entry);
our_pred->est_success_rate = 1e-3;
-#ifdef CACHE_IDS
- if (uid_unused == NULL)
- {
- struct passwd *pw;
-
- uid_allocated = ALLOC_STEP;
- uid_unused = xmalloc (uid_allocated);
- memset (uid_unused, 1, uid_allocated);
- setpwent ();
- while ((pw = getpwent ()) != NULL)
- {
- if ((unsigned) pw->pw_uid >= uid_allocated)
- {
- unsigned new_allocated = (unsigned) pw->pw_uid + ALLOC_STEP;
- uid_unused = xrealloc (uid_unused, new_allocated);
- memset (uid_unused + uid_allocated, 1,
- new_allocated - uid_allocated);
- uid_allocated = new_allocated;
- }
- uid_unused[(unsigned) pw->pw_uid] = 0;
- }
- endpwent ();
- }
-#endif
return true;
}
@@ -2639,7 +2575,7 @@ parse_version (const struct parser_table* entry, char **argv, int *arg_ptr)
printf (_("Features enabled: "));
#if CACHE_IDS
- printf ("CACHE_IDS ");
+ printf ("CACHE_IDS(ignored) ");
has_features = true;
#endif
#if DEBUG
diff --git a/find/pred.c b/find/pred.c
index 3a896797..32938fbd 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -741,31 +741,15 @@ pred_nogroup (const char *pathname, struct stat *stat_buf, struct predicate *pre
{
(void) pathname;
(void) pred_ptr;
-
-#ifdef CACHE_IDS
- extern char *gid_unused;
-
- return gid_unused[(unsigned) stat_buf->st_gid];
-#else
return getgrgid (stat_buf->st_gid) == NULL;
-#endif
}
bool
pred_nouser (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
{
-#ifdef CACHE_IDS
- extern char *uid_unused;
-#endif
-
(void) pathname;
(void) pred_ptr;
-
-#ifdef CACHE_IDS
- return uid_unused[(unsigned) stat_buf->st_uid];
-#else
return getpwuid (stat_buf->st_uid) == NULL;
-#endif
}