[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Findutils-patches] [PATCH 07/19] Fix Savannah bug #24283, find-4.5.2 -p
From: |
James Youngman |
Subject: |
[Findutils-patches] [PATCH 07/19] Fix Savannah bug #24283, find-4.5.2 -printf %TY causes NULL pointer dereference |
Date: |
Fri, 10 Apr 2009 23:53:04 +0100 |
---
NEWS | 2 ++
find/pred.c | 17 ++++++++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index fbaaf3b..3dd4483 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,8 @@ declarations to follow statements.
#25144: Misleading error message when argument to find -user is an
unknown user or is missing.
+#24283: -printf %TY causes NULL pointer dereference on Solaris.
+
#24169: find would segfault if the -newerXY test was not followed by
any argument.
diff --git a/find/pred.c b/find/pred.c
index 3a829bc..92da9fc 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -2068,7 +2068,7 @@ static char*
do_time_format (const char *fmt, const struct tm *p, const char *ns, size_t
ns_size)
{
static char *buf = NULL;
- static size_t buf_size = 0u;
+ static size_t buf_size;
char *timefmt = NULL;
boolean done = false;
struct tm altered_time;
@@ -2092,10 +2092,21 @@ do_time_format (const char *fmt, const struct tm *p,
const char *ns, size_t ns_s
else
altered_time.tm_sec += 11;
+ /* If we call strftime() with buf_size=0, the program will coredump
+ * on Solaris, since it unconditionally writes the terminating null
+ * character.
+ */
+ buf_size = 1u;
+ buf = xmalloc (buf_size);
while (!done)
{
- const size_t buf_used = strftime (buf, buf_size, timefmt, p);
- if (0 != buf_used)
+ /* I'm not sure that Solaris will return 0 when the buffer is too small.
+ * Therefore we do not check for (buf_used != 0) as the termination
+ * condition.
+ */
+ size_t buf_used = strftime (buf, buf_size, timefmt, p);
+ if (buf_used /* Conforming POSIX system */
+ && (buf_used < buf_size)) /* Solaris workaround */
{
char *altbuf;
size_t i, n;
--
1.5.6.5
- [Findutils-patches] [PATCH 00/19] *** SUBJECT HERE ***, James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 01/19] Applied doc patch from Stepan Kasal (backport), James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 02/19] Fix Savannah bug 22662 (nanoseconds wrongly appended after PM for find -printf %AX), James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 03/19] Fix bugs in bugfix for #22662, James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 04/19] Fixed Savannah bug #23663, crash in some locales for find -printf '%AX', James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 05/19] Fix bug #23996 (integer overflow when parsing "-used 3")., James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 06/19] Moved bugfixes in the NEWS file out of "Documentation Enhancements" into "Bug Fixes"., James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 07/19] Fix Savannah bug #24283, find-4.5.2 -printf %TY causes NULL pointer dereference,
James Youngman <=
- [Findutils-patches] [PATCH 08/19] Typo fix from Jim Meyering <address@hidden>, James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 09/19] fix a typo in a comment, James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 10/19] find: avoid using undefined statbuf, James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 11/19] find: Fix -regexptype parse specification bug: declare as POSOPT., James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 12/19] find: avoid warning about unused local, remove unnecessary include., James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 13/19] Really apply Jim's earlier patch., James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 14/19] Fix Savannah bug #25764, duplicate entry for proc in PRUNEFS., James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 15/19] Provide more detailed help on how to work with the git sources., James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 16/19] Ignore 'compile', James Youngman, 2009/04/10
- [Findutils-patches] [PATCH 17/19] Change suffix for non-release versions from -CVS to -git., James Youngman, 2009/04/10