Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2013-07-07 20:57:11 +0400
committerChristopher Faylor <me@cgf.cx>2013-07-07 20:57:11 +0400
commit40f11fc13318958f4a3f3af1fdd8c0c3b284de01 (patch)
treec975b4d0962e2a8de71adfbf1f0c7040cb43b2c0 /winsup/utils
parentb1b497cb2ebca568c41cd885d323c7c0719d4ce4 (diff)
* cygcheck.cc (dll_info): Detect and report on symlinks. Output wrong
architecture message inline with stdout for clarity. * path.cc (is_symlink): Always reset file pointer to beginning on exit. (readlink): Assume that file pointer is set to the beginning.
Diffstat (limited to 'winsup/utils')
-rw-r--r--winsup/utils/ChangeLog7
-rw-r--r--winsup/utils/cygcheck.cc23
-rw-r--r--winsup/utils/path.cc25
3 files changed, 38 insertions, 17 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog
index 6eab6b341..b69b83317 100644
--- a/winsup/utils/ChangeLog
+++ b/winsup/utils/ChangeLog
@@ -1,3 +1,10 @@
+2013-07-07 Christopher Faylor <me.cygwin2013@cgf.cx>
+
+ * cygcheck.cc (dll_info): Detect and report on symlinks. Output wrong
+ architecture message inline with stdout for clarity.
+ * path.cc (is_symlink): Always reset file pointer to beginning on exit.
+ (readlink): Assume that file pointer is set to the beginning.
+
2013-06-26 Corinna Vinschen <corinna@vinschen.de>
* cygpath.cc (do_pathconv): when -p option is given, generate wide
diff --git a/winsup/utils/cygcheck.cc b/winsup/utils/cygcheck.cc
index 8c7af0e1c..0447e585a 100644
--- a/winsup/utils/cygcheck.cc
+++ b/winsup/utils/cygcheck.cc
@@ -590,11 +590,26 @@ cygwin_info (HANDLE h)
return;
}
+/* Special case. Don't complain about this one. */
+#define CYGLSA64_DLL "\\cyglsa64.dll"
+
static void
dll_info (const char *path, HANDLE fh, int lvl, int recurse)
{
DWORD junk;
int i;
+ if (is_symlink (fh))
+ {
+ if (!verbose)
+ puts ("");
+ else
+ {
+ char buf[PATH_MAX + 1] = "";
+ readlink (fh, buf, sizeof(buf) - 1);
+ printf (" (symlink to %s)\n", buf);
+ }
+ return;
+ }
int pe_header_offset = get_dword (fh, 0x3c);
if (GetLastError () != NO_ERROR)
display_error ("get_dword");
@@ -604,18 +619,14 @@ dll_info (const char *path, HANDLE fh, int lvl, int recurse)
#ifdef __x86_64__
if (arch != IMAGE_FILE_MACHINE_AMD64)
{
- fputc ('\n', stderr);
- display_error ("Wrong architecture. Only x86_64 executables supported.",
- false, false);
+ puts (verbose ? " (not x86_64 dll)" : "\n");
return;
}
int base_off = 108;
#else
if (arch != IMAGE_FILE_MACHINE_I386)
{
- fputc ('\n', stderr);
- display_error ("Wrong architecture. Only ix86 executables supported.",
- false, false);
+ puts (verbose ? " (not x86 dll)" : "\n");
return;
}
int base_off = 92;
diff --git a/winsup/utils/path.cc b/winsup/utils/path.cc
index a66dcdc14..d1d01e92b 100644
--- a/winsup/utils/path.cc
+++ b/winsup/utils/path.cc
@@ -140,9 +140,10 @@ is_exe (HANDLE fh)
bool
is_symlink (HANDLE fh)
{
+ bool ret = false;
int magic = get_word (fh, 0x0);
if (magic != SHORTCUT_MAGIC && magic != SYMLINK_MAGIC)
- return false;
+ goto out;
DWORD got;
BY_HANDLE_FILE_INFORMATION local;
if (!GetFileInformationByHandle (fh, &local))
@@ -151,31 +152,34 @@ is_symlink (HANDLE fh)
{
DWORD size;
if (!local.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
- return false; /* Not a Cygwin symlink. */
+ goto out; /* Not a Cygwin symlink. */
if ((size = GetFileSize (fh, NULL)) > 8192)
- return false; /* Not a Cygwin symlink. */
+ goto out; /* Not a Cygwin symlink. */
char buf[size];
SetFilePointer (fh, 0, 0, FILE_BEGIN);
if (!ReadFile (fh, buf, size, &got, 0))
- return false;
+ goto out;
if (got != size || !cmp_shortcut_header ((win_shortcut_hdr *) buf))
- return false; /* Not a Cygwin symlink. */
+ goto out; /* Not a Cygwin symlink. */
/* TODO: check for invalid path contents
(see symlink_info::check() in ../cygwin/path.cc) */
}
else /* magic == SYMLINK_MAGIC */
{
if (!local.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)
- return false; /* Not a Cygwin symlink. */
+ goto out; /* Not a Cygwin symlink. */
char buf[sizeof (SYMLINK_COOKIE) - 1];
SetFilePointer (fh, 0, 0, FILE_BEGIN);
if (!ReadFile (fh, buf, sizeof (buf), &got, 0))
- return false;
+ goto out;
if (got != sizeof (buf) ||
memcmp (buf, SYMLINK_COOKIE, sizeof (buf)) != 0)
- return false; /* Not a Cygwin symlink. */
+ goto out; /* Not a Cygwin symlink. */
}
- return true;
+ ret = true;
+out:
+ SetFilePointer (fh, 0, 0, FILE_BEGIN);
+ return ret;
}
/* Assumes is_symlink(fh) is true */
@@ -196,8 +200,7 @@ readlink (HANDLE fh, char *path, int maxlen)
buf = (char *) alloca (fi.nFileSizeLow + 1);
file_header = (win_shortcut_hdr *) buf;
- if (SetFilePointer (fh, 0L, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER
- || !ReadFile (fh, buf, fi.nFileSizeLow, &rv, NULL)
+ if (!ReadFile (fh, buf, fi.nFileSizeLow, &rv, NULL)
|| rv != fi.nFileSizeLow)
return false;