1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
<F28>diff -U8 atftp-0.7.2/tftp_io.c /var/tmp/portage/net-ftp/atftp-0.7.2-r1/work/atftp-0.7.2/tftp_io.c
--- atftp-0.7.2/tftp_io.c 2019-04-14 17:38:55.000000000 -0500
+++ /var/tmp/portage/net-ftp/atftp-0.7.2-r1/work/atftp-0.7.2/tftp_io.c 2020-03-16 12:55:22.371820662 -0500
@@ -439,26 +439,32 @@
}
/*
* Write to file and do netascii conversion if needed
*/
int tftp_file_write(FILE *fp, char *data_buffer, int data_buffer_size, long block_number, int data_size,
int convert, long *prev_block_number, int *temp)
{
+ static long filepos;
int bytes_written;
int c;
char prevchar = *temp;
if (!convert)
{
/* Simple case, just seek and write */
- if (fseek(fp, (block_number - 1) * data_buffer_size, SEEK_SET) != 0)
- return 0;
+ long position = (block_number - 1)*data_buffer_size;
+ if (position != filepos)
+ if (fseek(fp, position, SEEK_SET) != 0)
+ return 0;
+ else
+ filepos = position;
bytes_written = fwrite(data_buffer, 1, data_size, fp);
+ filepos += bytes_written;
}
else if (block_number != *prev_block_number)
{
/*
* Same principle than for reading, but simpler since when client
* send same block twice there is no need to rewrite it to the
* file
*/
|