[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Release of version 4.14.2 of sharutils
From: |
Eric Blake |
Subject: |
Re: Release of version 4.14.2 of sharutils |
Date: |
Mon, 22 Dec 2014 11:43:16 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 |
On 12/22/2014 11:25 AM, Eric Blake wrote:
>
> You still have a bug that needs fixing:
>
> shar.c: In function 'walktree':
> shar.c:577:5: warning: implicit declaration of function 'basename'
> [-Wimplicit-function-declaration]
> restore_name = basename (local_name_copy);
> ^
> shar.c:577:18: warning: assignment makes pointer from integer without a
> cast [enabled by default]
> restore_name = basename (local_name_copy);
> ^
>
> On 32-bit cygwin, 'int' and 'void*' are the same width, so the correct
> thing happens in spite of the bad coding, and the testsuite passes; but
> on 64-bit cygwin, since 'int' is truncated, and the memory layout
> intentionally sticks heap pointers outside the first 4G, you are
> corrupting the value returned by basename by integer truncation before
> re-expansion back to a pointer, and this causes a testsuite failure:
Sure enough, this patch was sufficient to avoid the testsuite failure on
64-bit cygwin:
diff --git i/src/shar.c w/src/shar.c
index fd7cf41..47ad514 100644
--- i/src/shar.c
+++ w/src/shar.c
@@ -50,6 +50,7 @@ static const char cright_years_z[] =
# include <limits.h>
#endif
#include <time.h>
+#include <libgen.h>
#include "inttostr.h"
#include "liballoca.h"
That said,
> basename() is non-portable, and not thread-safe; it's better to use
> gnulib's base_name() function.
I still stand by this advice; gnulib intentionally does not guarantee
<libgen.h> (and it is missing on at least mingw), because basename() is
not the right function to be using if you care about systems with drive
letters.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature