* mount.cc (mount_info::from_fstab): Use proper buffer size.

This commit is contained in:
Christopher Faylor 2008-05-25 23:51:32 +00:00
parent f524521aab
commit 12cf19762d
2 changed files with 7 additions and 4 deletions

View File

@ -1,3 +1,7 @@
2008-05-25 Christopher Faylor <me+cygwin@cgf.cx>
* mount.cc (mount_info::from_fstab): Use proper buffer size.
2008-05-24 Christopher Faylor <me+cygwin@cgf.cx> 2008-05-24 Christopher Faylor <me+cygwin@cgf.cx>
* mount.cc (mount_info::init): Revert previous change. * mount.cc (mount_info::init): Revert previous change.

View File

@ -935,9 +935,8 @@ mount_info::from_fstab (bool user, WCHAR fstab[], PWCHAR fstab_end)
char buf[NT_MAX_PATH]; char buf[NT_MAX_PATH];
char *got = buf; char *got = buf;
DWORD len = 0; DWORD len = 0;
/* Using NT_MAX_PATH-1 leaves space to append two \0. */ /* Using buffer size - 1 leaves space to append two \0. */
while (ReadFile (h, got, (NT_MAX_PATH - 1) * sizeof (WCHAR) - (got - buf), while (ReadFile (h, got, (sizeof (buf) - 1) - (got - buf), &len, NULL))
&len, NULL))
{ {
char *end; char *end;
@ -954,7 +953,7 @@ mount_info::from_fstab (bool user, WCHAR fstab[], PWCHAR fstab_end)
goto done; goto done;
got = end + 1; got = end + 1;
} }
if (len < (NT_MAX_PATH - 1) * sizeof (WCHAR)) if (len < (sizeof (buf) - 1))
break; break;
/* We have to read once more. Move remaining bytes to the start of /* 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 buffer and reposition got so that it points to the end of