lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] tftp_server.c read problem


From: Gisle Vanem
Subject: [lwip-devel] tftp_server.c read problem
Date: Thu, 9 Mar 2017 19:51:03 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0

I wanted to try tftp transfer on Windows. Hence I copied
the tftp-serving code from simhost.c. But ran into
problems on reading and storing files that was not a
multiple of 512 bytes (they seldom are). I got a truncated
file.

Seems to be related to this:

tftp_read(void* handle, void* buf, int bytes)
{
  if (fread(buf, 1, bytes, (FILE*)handle) != (size_t)bytes) {
    return -1;
  }

Shouldn't it be:
  int ret = (int)fread (buf, 1, bytes, (FILE*)handle);
  if (ret <= 0)
     return (-1);
  return (ret);

Thus allowing tftp_server.c to not close the session on
a short fread()?

PS. I used curl as the tftp-client.

-- 
--gv



reply via email to

[Prev in Thread] Current Thread [Next in Thread]