From 902ee9ccafffe018b212e1ec4918a123009fcec2 Mon Sep 17 00:00:00 2001 From: okuji Date: Sat, 13 Oct 2001 13:07:40 +0000 Subject: [PATCH] Fix a bug in tftp_read, which may appear when seeking back. --- ChangeLog | 7 +++++++ netboot/fsys_tftp.c | 22 ++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 346615302..9cf5ec33f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-10-13 Yoshinori K. Okuji + + * 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 Don't use get_diskinfo_floppy. Reported by Ben Liblit diff --git a/netboot/fsys_tftp.c b/netboot/fsys_tftp.c index 627195f92..2bc2f25c1 100644 --- a/netboot/fsys_tftp.c +++ b/netboot/fsys_tftp.c @@ -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. */