Fix a bug in tftp_read, which may appear when seeking back.

This commit is contained in:
okuji 2001-10-13 13:07:40 +00:00
parent 3785f597a0
commit 902ee9ccaf
2 changed files with 21 additions and 8 deletions

View file

@ -1,3 +1,10 @@
2001-10-13 Yoshinori K. Okuji <okuji@gnu.org>
* netboot/fsys_tftp.c (tftp_read): Move the unused data
forwards, only if AMT is more than zero. If AMT is not positive,
subtract BUF_READ from SAVED_FILEPOS and set BUF_READ to zero,
to skip the whole buffer. Reported by Frank Mehnert.
2001-10-13 Yoshinori K. Okuji <okuji@gnu.org>
Don't use get_diskinfo_floppy. Reported by Ben Liblit

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2000 Free Software Foundation, Inc.
* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -367,15 +367,21 @@ tftp_read (char *addr, int size)
addr += amt;
filepos += amt;
ret += amt;
}
/* If the size of the empty space becomes small, move the unused
data forwards. */
if (filepos - saved_filepos > FSYS_BUFLEN / 2)
/* If the size of the empty space becomes small, move the unused
data forwards. */
if (filepos - saved_filepos > FSYS_BUFLEN / 2)
{
grub_memmove (buf, buf + FSYS_BUFLEN / 2, FSYS_BUFLEN / 2);
buf_read -= FSYS_BUFLEN / 2;
saved_filepos += FSYS_BUFLEN / 2;
}
}
else
{
grub_memmove (buf, buf + FSYS_BUFLEN / 2, FSYS_BUFLEN / 2);
buf_read -= FSYS_BUFLEN / 2;
saved_filepos += FSYS_BUFLEN / 2;
/* Skip the whole buffer. */
saved_filepos += buf_read;
buf_read = 0;
}
/* Read the data. */