lwip-devel
[Top][All Lists]
Advanced

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

Re: [lwip-devel] tftp_server.c read problem


From: Dirk Ziegelmeier
Subject: Re: [lwip-devel] tftp_server.c read problem
Date: Thu, 9 Mar 2017 21:09:05 +0100

correct, thanks for reporting!


Ciao
Dirk

--
Dirk Ziegelmeier * address@hidden * http://www.ziegelmeier.net

On Thu, Mar 9, 2017 at 7:51 PM, Gisle Vanem <address@hidden> wrote:
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

_______________________________________________
lwip-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-devel


reply via email to

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