[U-Boot-Users] [PATCH] fixed tftp error message output

Wolfgang Denk wd at denx.de
Sun Jul 20 14:53:02 CEST 2003


In message <1058653888.774.80.camel at localhost> you wrote:
>
> > Nothing wrong, or am I missing something?
> 
> My guess is that your tftp server correctly appends \0 to the error
> message and atftpd does not. Strange. Having a look at atftpd source
> code I suspect that its use of strncpy for the error message is the
> cause, but I think u-boot should not rely on the trailing \0, because
> the length of the error message is known anyway. I'll report when I have
> been able to test it.

The TFTP protocol explicitely requires the error string  to  be  '\0'
terminated:

Quote from RFC 1350 "THE TFTP PROTOCOL (REVISION 2)":

   ...
               2 bytes     2 bytes      string    1 byte
               -----------------------------------------
              | Opcode |  ErrorCode |   ErrMsg   |   0  |
               -----------------------------------------

                        Figure 5-4: ERROR packet

   An ERROR packet (opcode 5) takes the form depicted in Figure 5-4.  An
   ERROR packet can be the acknowledgment of any other type of packet.
   The error code is an integer indicating the nature of the error.  A
   table of values and meanings is given in the appendix.  (Note that
   several error codes have been added to this version of this
   document.) The error message is intended for human consumption, and
   should be in netascii.  Like all other strings, it is terminated with
   a zero byte.
   ...

IMHO the "it is terminated with a zero  byte"  is  mandatory,  so  no
change to U-Boot sems to be necessary.


Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
Documentation is like sex: when it is good, it is  very,  very  good;
and when it is bad, it is better than nothing.         - Dick Brandon




More information about the U-Boot mailing list