fix the bug in RRQ completely!
This commit is contained in:
parent
f6e3c77ef1
commit
8ba5340fb8
2 changed files with 34 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2000-05-25 OKUJI Yoshinori <okuji@gnu.org>
|
||||||
|
|
||||||
|
* netboot/fsys_tftp.c (buf_fill): Warn when amazing things
|
||||||
|
happen.
|
||||||
|
(tftp_dir): Revert previous change. Don't use TFTP_MIN_PACKET
|
||||||
|
but calculate the appropriate length.
|
||||||
|
|
||||||
2000-05-23 OKUJI Yoshinori <okuji@gnu.org>
|
2000-05-23 OKUJI Yoshinori <okuji@gnu.org>
|
||||||
|
|
||||||
* netboot/fsys_tftp.c (tftp_dir): Append "0\0" to the request
|
* netboot/fsys_tftp.c (tftp_dir): Append "0\0" to the request
|
||||||
|
|
|
@ -116,8 +116,12 @@ buf_fill (int abort)
|
||||||
#endif
|
#endif
|
||||||
/* Shouldn't happen. */
|
/* Shouldn't happen. */
|
||||||
if (prevblock)
|
if (prevblock)
|
||||||
/* Ignore it. */
|
{
|
||||||
continue;
|
/* Ignore it. */
|
||||||
|
grub_printf ("%s:%d: warning: PREVBLOCK != 0 (0x%x)\n",
|
||||||
|
__FILE__, __LINE__, prevblock);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
len = ntohs (tr->udp.len) - sizeof (struct udphdr) - 2;
|
len = ntohs (tr->udp.len) - sizeof (struct udphdr) - 2;
|
||||||
if (len > TFTP_MAX_PACKET)
|
if (len > TFTP_MAX_PACKET)
|
||||||
|
@ -187,8 +191,12 @@ buf_fill (int abort)
|
||||||
|
|
||||||
/* Shouldn't happen. */
|
/* Shouldn't happen. */
|
||||||
if (len > packetsize)
|
if (len > packetsize)
|
||||||
/* Ignore it. */
|
{
|
||||||
continue;
|
/* Ignore it. */
|
||||||
|
grub_printf ("%s:%d: warning: LEN > PACKETSIZE (0x%x > 0x%x)\n",
|
||||||
|
__FILE__, __LINE__, len, packetsize);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
block = ntohs (tp.u.ack.block = tr->u.data.block);
|
block = ntohs (tp.u.ack.block = tr->u.data.block);
|
||||||
}
|
}
|
||||||
|
@ -268,6 +276,18 @@ send_rrq (void)
|
||||||
|
|
||||||
#ifdef TFTP_DEBUG
|
#ifdef TFTP_DEBUG
|
||||||
grub_printf ("send_rrq ()\n");
|
grub_printf ("send_rrq ()\n");
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
for (i = 0, p = (char *) &tp; i < len; i++)
|
||||||
|
if (p[i] >= ' ' && p[i] <= '~')
|
||||||
|
grub_putchar (p[i]);
|
||||||
|
else
|
||||||
|
grub_printf ("\\%x", (unsigned) p[i]);
|
||||||
|
|
||||||
|
grub_putchar ('\n');
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Send the packet. */
|
/* Send the packet. */
|
||||||
return udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr, ++iport,
|
return udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr, ++iport,
|
||||||
|
@ -401,9 +421,9 @@ tftp_dir (char *dirname)
|
||||||
ch = nul_terminate (dirname);
|
ch = nul_terminate (dirname);
|
||||||
/* Make the request string (octet, blksize and tsize). */
|
/* Make the request string (octet, blksize and tsize). */
|
||||||
len = (grub_sprintf ((char *) tp.u.rrq,
|
len = (grub_sprintf ((char *) tp.u.rrq,
|
||||||
"%s%coctet%cblksize%c%d%ctsize%c0%c0",
|
"%s%coctet%cblksize%c%d%ctsize%c0",
|
||||||
dirname, 0, 0, 0, TFTP_MAX_PACKET, 0, 0, 0)
|
dirname, 0, 0, 0, TFTP_MAX_PACKET, 0, 0)
|
||||||
+ TFTP_MIN_PACKET + 1);
|
+ sizeof (struct iphdr) + sizeof (struct udphdr) + 2 + 1);
|
||||||
/* Restore the original DIRNAME. */
|
/* Restore the original DIRNAME. */
|
||||||
dirname[grub_strlen (dirname)] = ch;
|
dirname[grub_strlen (dirname)] = ch;
|
||||||
/* Save the TFTP packet so that we can reopen the file later. */
|
/* Save the TFTP packet so that we can reopen the file later. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue