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
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2008-06-10 21:17:44 +0400
committerCorinna Vinschen <corinna@vinschen.de>2008-06-10 21:17:44 +0400
commit58014a9b461716e21e1b273155c379956b3cca36 (patch)
treed67274f5f49ac826b0ddc028f76397134fac8ad5 /winsup
parent93e9098f7c0c7cf16776ebd41e373551e6323726 (diff)
* mount.cc (mount_info::from_fstab): Read sizeof (buf) - 2 bytes.
Add code to handle overly long lines.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/mount.cc32
2 files changed, 34 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 38e81276a..64bf80ce4 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,10 @@
2008-06-10 Corinna Vinschen <corinna@vinschen.de>
+ * mount.cc (mount_info::from_fstab): Read sizeof (buf) - 2 bytes.
+ Add code to handle overly long lines.
+
+2008-06-10 Corinna Vinschen <corinna@vinschen.de>
+
* sec_auth.cc (lsaauth): Make returned token inheritable.
2008-06-10 Corinna Vinschen <corinna@vinschen.de>
diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc
index 8aa304ea4..1c11d869e 100644
--- a/winsup/cygwin/mount.cc
+++ b/winsup/cygwin/mount.cc
@@ -935,8 +935,9 @@ mount_info::from_fstab (bool user, WCHAR fstab[], PWCHAR fstab_end)
char buf[NT_MAX_PATH];
char *got = buf;
DWORD len = 0;
- /* Using buffer size - 1 leaves space to append two \0. */
- while (ReadFile (h, got, (sizeof (buf) - 1) - (got - buf), &len, NULL))
+ unsigned line = 1;
+ /* Using buffer size - 2 leaves space to append two \0. */
+ while (ReadFile (h, got, (sizeof (buf) - 2) - (got - buf), &len, NULL))
{
char *end;
@@ -946,15 +947,39 @@ mount_info::from_fstab (bool user, WCHAR fstab[], PWCHAR fstab_end)
len += got - buf;
/* Reset got to start reading at the start of the buffer again. */
got = buf;
+retry:
+ bool got_nl = false;
while (got < buf + len && (end = strchr (got, '\n')))
{
+ got_nl = true;
end[end[-1] == '\r' ? -1 : 0] = '\0';
if (!from_fstab_line (got, user))
goto done;
got = end + 1;
+ ++line;
}
- if (len < (sizeof (buf) - 1))
+ if (len < (sizeof (buf) - 2))
break;
+ /* Check if the buffer contained at least one \n. If not, the
+ line length is > 32K. We don't take such long lines. Print
+ a debug message and skip this line entirely. */
+ if (!got_nl)
+ {
+ system_printf ("%W: Line %d too long, skipping...", fstab, line);
+ while (ReadFile (h, buf, (sizeof (buf) - 2), &len, NULL))
+ {
+ buf[len] = buf[len + 1] = '\0';
+ got = strchr (buf, '\n');
+ if (got)
+ {
+ ++got;
+ ++line;
+ goto retry;
+ }
+ }
+ got = buf;
+ break;
+ }
/* We have to read once more. Move remaining bytes to the start of
the buffer and reposition got so that it points to the end of
the remaining bytes. */
@@ -963,6 +988,7 @@ mount_info::from_fstab (bool user, WCHAR fstab[], PWCHAR fstab_end)
got = buf + len;
buf[len] = buf[len + 1] = '\0';
}
+ /* Catch a last line without trailing \n. */
if (got > buf)
from_fstab_line (got, user);
done: