public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ben Warren <biggerbadderben@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] TFTP: add host ip addr support
Date: Wed, 16 Jan 2008 15:27:50 -0500	[thread overview]
Message-ID: <478E68C6.8070309@gmail.com> (raw)
In-Reply-To: <20080116173322.GF31365@game.jcrosoft.org>

Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:49 Wed 16 Jan     , Ben Warren wrote:
>   
>> Jean-Christophe PLAGNIOL-VILLARD wrote:
>>     
>>> On 22:19 Tue 15 Jan     , Ben Warren wrote:
>>>   
>>>       
>>>> Jean-Christophe PLAGNIOL-VILLARD wrote:
>>>>     
>>>>         
>>>>> allow to use a different server as set in serverip
>>>>>
>>>>> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
>>>>>
>>>>> diff --git a/common/cmd_net.c b/common/cmd_net.c
>>>>> index 21682c0..b86ca86 100644
>>>>> --- a/common/cmd_net.c
>>>>> +++ b/common/cmd_net.c
>>>>> @@ -51,7 +51,7 @@ int do_tftpb (cmd_tbl_t *cmdtp, int flag, int argc, char 
>>>>> *argv[])
>>>>>  U_BOOT_CMD(
>>>>>  	tftpboot,	3,	1,	do_tftpb,
>>>>>  	"tftpboot- boot image via network using TFTP protocol\n",
>>>>> -	"[loadAddress] [bootfilename]\n"
>>>>> +	"[loadAddress] [[hostIPaddr:]bootfilename]\n"
>>>>>  );
>>>>>   int do_rarpb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
>>>>> diff --git a/net/tftp.c b/net/tftp.c
>>>>> index 8b95bcf..9d87e2c 100644
>>>>> --- a/net/tftp.c
>>>>> +++ b/net/tftp.c
>>>>> @@ -34,7 +34,7 @@
>>>>>  #define TFTP_ERROR	5
>>>>>  #define TFTP_OACK	6
>>>>>  -
>>>>> +static IPaddr_t TftpServerIP;
>>>>>  static int	TftpServerPort;		/* The UDP port at their end		*/
>>>>>  static int	TftpOurPort;		/* The UDP port at our end		*/
>>>>>  static int	TftpTimeoutCount;
>>>>> @@ -55,7 +55,7 @@ static int	TftpState;
>>>>>   #define DEFAULT_NAME_LEN	(8 + 4 + 1)
>>>>>  static char default_filename[DEFAULT_NAME_LEN];
>>>>> -static char *tftp_filename;
>>>>> +static char tftp_filename[2048];
>>>>>   
>>>>>       
>>>>>           
>>>> A 2k filename??? How about something more reasonable like 80 or 100 bytes. 
>>>> Use a #define for the size so you can use it later.
>>>>     
>>>>         
>>> I've chosed to use the same filename size as nfs.
>>>   
>>>       
>> Then NFS uses too big a buffer. Please make this one smaller, use a 
>> #define and strncpy.
>> <snip>
>>     
> OK about the buffer size.
>
> But I diaagree about strncpy because you need to known the size of
> the string and we know it only when we use the default_filename otherwise
> we need to strlen and in this strcpy do every thing itself.
>
>   
strncpy copies AT MOST 'n' bytes.

#define MAX_FILE_NAME_LEN 80
static char tftp_filename[MAX_FILE_NAME_LEN];

strncpy(tftp_filename, str, MAX_FILE_NAME_LEN);

Standard buffer overrun protection.

regards,
Ben

  reply	other threads:[~2008-01-16 20:27 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-11 23:43 [U-Boot-Users] [PATCH] TFTP: add host ip addr support Jean-Christophe PLAGNIOL-VILLARD
2008-01-15 13:50 ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-16  3:19 ` Ben Warren
2008-01-16  7:19   ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-16 15:49     ` Ben Warren
2008-01-16 17:33       ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-16 20:27         ` Ben Warren [this message]
2008-01-16 20:40           ` Wolfgang Denk
2008-01-16 20:47             ` Ben Warren
2008-01-16 20:56               ` McMullan, Jason
2008-01-16 21:26                 ` Wolfgang Denk
2008-01-16 22:27                   ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-16 23:09                     ` Wolfgang Denk
2008-01-16 23:33                       ` Ben Warren
2008-01-17 22:08                         ` [U-Boot-Users] [PATCH 0/1] " Jean-Christophe PLAGNIOL-VILLARD
2008-01-17 22:08                           ` [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional Jean-Christophe PLAGNIOL-VILLARD
2008-01-17 22:29                             ` Ben Warren
2008-01-17 22:31                           ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support Wolfgang Denk
2008-01-17 22:42                           ` Andre Renaud
2008-01-18  0:19                             ` Ben Warren
2008-01-18  0:30                             ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-16 21:23               ` [U-Boot-Users] [PATCH] " Wolfgang Denk
2008-01-16 21:38                 ` Ben Warren
2008-01-17 23:51                 ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-18  0:14                   ` Jean-Christophe PLAGNIOL-VILLARD
2008-02-04 23:42                     ` Wolfgang Denk
2008-01-18  0:23                   ` Ben Warren
  -- strict thread matches above, loose matches on Subject: below --
2007-12-24 15:55 Jean-Christophe PLAGNIOL-VILLARD
2007-12-24 16:40 ` Jerry Van Baren
2007-12-26 20:42 ` Haavard Skinnemoen
2007-12-26 23:09   ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=478E68C6.8070309@gmail.com \
    --to=biggerbadderben@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox