From 12cf19762d07e477c5c58419cb522e393bee2e0c Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 25 May 2008 23:51:32 +0000 Subject: [PATCH] * mount.cc (mount_info::from_fstab): Use proper buffer size. --- winsup/cygwin/ChangeLog | 4 ++++ winsup/cygwin/mount.cc | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 315cd3a69..e267ea4b5 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2008-05-25 Christopher Faylor + + * mount.cc (mount_info::from_fstab): Use proper buffer size. + 2008-05-24 Christopher Faylor * mount.cc (mount_info::init): Revert previous change. diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc index 298c00f0a..8aa304ea4 100644 --- a/winsup/cygwin/mount.cc +++ b/winsup/cygwin/mount.cc @@ -935,9 +935,8 @@ mount_info::from_fstab (bool user, WCHAR fstab[], PWCHAR fstab_end) char buf[NT_MAX_PATH]; char *got = buf; DWORD len = 0; - /* Using NT_MAX_PATH-1 leaves space to append two \0. */ - while (ReadFile (h, got, (NT_MAX_PATH - 1) * sizeof (WCHAR) - (got - buf), - &len, NULL)) + /* Using buffer size - 1 leaves space to append two \0. */ + while (ReadFile (h, got, (sizeof (buf) - 1) - (got - buf), &len, NULL)) { char *end; @@ -954,7 +953,7 @@ mount_info::from_fstab (bool user, WCHAR fstab[], PWCHAR fstab_end) goto done; got = end + 1; } - if (len < (NT_MAX_PATH - 1) * sizeof (WCHAR)) + if (len < (sizeof (buf) - 1)) 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