diff mbox

[U-Boot] net: Increase the size of the net_boot_file_name buffer

Message ID 1443622325-30792-1-git-send-email-j-stiffler@ti.com
State Accepted
Delegated to: Joe Hershberger
Headers show

Commit Message

Jacob Stiffler Sept. 30, 2015, 2:12 p.m. UTC
The net_boot_file_name buffer is used as storage for the bootfilename
command line argument to network boot commands such as tftp and nfs.

Increase the size of this buffer to 1024 bytes as the current size of
128 bytes is restrictive for arbitrary paths on the server.

Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
---
 include/net.h | 2 +-
 net/net.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Wolfgang Denk Oct. 1, 2015, 2:27 p.m. UTC | #1
Dear Jacob,

In message <1443622325-30792-1-git-send-email-j-stiffler@ti.com> you wrote:
> The net_boot_file_name buffer is used as storage for the bootfilename
> command line argument to network boot commands such as tftp and nfs.
> 
> Increase the size of this buffer to 1024 bytes as the current size of
> 128 bytes is restrictive for arbitrary paths on the server.

According to RFC 2131, the boot file name has a fixed size of 128
octets.

Best regards,

Wolfgang Denk
Jacob Stiffler Oct. 1, 2015, 5:31 p.m. UTC | #2
On 10/1/2015 10:27 AM, Wolfgang Denk wrote:
> Dear Jacob,
>
> In message <1443622325-30792-1-git-send-email-j-stiffler@ti.com> you wrote:
>> The net_boot_file_name buffer is used as storage for the bootfilename
>> command line argument to network boot commands such as tftp and nfs.
>>
>> Increase the size of this buffer to 1024 bytes as the current size of
>> 128 bytes is restrictive for arbitrary paths on the server.
> According to RFC 2131, the boot file name has a fixed size of 128
> octets.

Wolfgang,

Yes. However, the global "net_boot_file_name" is not only used for 
BOOTP, but also for NFS and TFTP.

"net_boot_file_name" appears to be temporary storage to supply the file 
path to arbitrary protocols from the command line arguments.

The "file" field in the bootp message is fixed at 128 octets in the 
"bootp_hdr" structure.

The contents of "net_boot_file_name" are read or written using the 
standard "strncopy()" or the similar "copy_filename()", so there should 
be any issue with respect to memory leaks.

Thank you,
Jacob Stiffler

> Best regards,
>
> Wolfgang Denk
>
Wolfgang Denk Oct. 1, 2015, 8:07 p.m. UTC | #3
Dear Jacob,

In message <560D6DE3.8070901@ti.com> you wrote:
> 
> Yes. However, the global "net_boot_file_name" is not only used for 
> BOOTP, but also for NFS and TFTP.
> 
> "net_boot_file_name" appears to be temporary storage to supply the file 
> path to arbitrary protocols from the command line arguments.

I see.

> The "file" field in the bootp message is fixed at 128 octets in the 
> "bootp_hdr" structure.
> 
> The contents of "net_boot_file_name" are read or written using the 
> standard "strncopy()" or the similar "copy_filename()", so there should 
> be any issue with respect to memory leaks.

I guess you mean there should NOT be any issue?

Best regards,

Wolfgang Denk
Jacob Stiffler Oct. 1, 2015, 8:11 p.m. UTC | #4
On 10/1/2015 4:07 PM, Wolfgang Denk wrote:
> Dear Jacob,
>
> In message <560D6DE3.8070901@ti.com> you wrote:
>> Yes. However, the global "net_boot_file_name" is not only used for
>> BOOTP, but also for NFS and TFTP.
>>
>> "net_boot_file_name" appears to be temporary storage to supply the file
>> path to arbitrary protocols from the command line arguments.
> I see.
>
>> The "file" field in the bootp message is fixed at 128 octets in the
>> "bootp_hdr" structure.
>>
>> The contents of "net_boot_file_name" are read or written using the
>> standard "strncopy()" or the similar "copy_filename()", so there should
>> be any issue with respect to memory leaks.
> I guess you mean there should NOT be any issue?

Yes, sorry. There should not be any issue with respect to memory leaks.

Thank you,
Jacob Stiffler

> Best regards,
>
> Wolfgang Denk
>
Stefan BrĂ¼ns Oct. 3, 2015, 2:13 p.m. UTC | #5
On Thursday 01 October 2015 16:27:11 Wolfgang Denk wrote:
> Dear Jacob,
> 
> In message <1443622325-30792-1-git-send-email-j-stiffler@ti.com> you wrote:
> > The net_boot_file_name buffer is used as storage for the bootfilename
> > command line argument to network boot commands such as tftp and nfs.
> > 
> > Increase the size of this buffer to 1024 bytes as the current size of
> > 128 bytes is restrictive for arbitrary paths on the server.
> 
> According to RFC 2131, the boot file name has a fixed size of 128
> octets.

You can also put the file name into Option 67, which results in a length limit 
of 255 octets (DHCP option length limit).

I sent patches with several DHCP enhancements, including Option 67 support, to 
the ML a few weeks ago.

Kind regards,

Stefan
Otavio Salvador Oct. 3, 2015, 2:41 p.m. UTC | #6
On Sat, Oct 3, 2015 at 11:13 AM, Stefan Bruens
<stefan.bruens@rwth-aachen.de> wrote:
> On Thursday 01 October 2015 16:27:11 Wolfgang Denk wrote:
>> Dear Jacob,
>>
>> In message <1443622325-30792-1-git-send-email-j-stiffler@ti.com> you wrote:
>> > The net_boot_file_name buffer is used as storage for the bootfilename
>> > command line argument to network boot commands such as tftp and nfs.
>> >
>> > Increase the size of this buffer to 1024 bytes as the current size of
>> > 128 bytes is restrictive for arbitrary paths on the server.
>>
>> According to RFC 2131, the boot file name has a fixed size of 128
>> octets.
>
> You can also put the file name into Option 67, which results in a length limit
> of 255 octets (DHCP option length limit).
>
> I sent patches with several DHCP enhancements, including Option 67 support, to
> the ML a few weeks ago.

Has those patches been applied? otherwise it would be good to rebase
it and send them again as we are close of release and merge window
will soon open.
Jacob Stiffler Oct. 6, 2015, 5:26 p.m. UTC | #7
> On Sat, Oct 3, 2015 at 11:13 AM, Stefan Bruens
> <stefan.bruens@rwth-aachen.de> wrote:
> > On Thursday 01 October 2015 16:27:11 Wolfgang Denk wrote:
> >> Dear Jacob,
> >>
> >> In message <1443622325-30792-1-git-send-email-j-stiffler@ti.com> you wrote:
> >> > The net_boot_file_name buffer is used as storage for the bootfilename
> >> > command line argument to network boot commands such as tftp and nfs.
> >> >
> >> > Increase the size of this buffer to 1024 bytes as the current size of
> >> > 128 bytes is restrictive for arbitrary paths on the server.
> >>
> >> According to RFC 2131, the boot file name has a fixed size of 128
> >> octets.
> >
> > You can also put the file name into Option 67, which results in a length limit
> > of 255 octets (DHCP option length limit).
> >
> > I sent patches with several DHCP enhancements, including Option 67 support, to
> > the ML a few weeks ago.
>
> Has those patches been applied? otherwise it would be good to rebase
> it and send them again as we are close of release and merge window
> will soon open.
The intent of this patch is not to increase the size of the path for bootp, but to
increase the size of the path for nfs and tftp. The "net_boot_file_name" is a common
global variable used for all network commands which load files into memory, and is
basically temporary storage.
Joe Hershberger Oct. 28, 2015, 8:09 p.m. UTC | #8
Hi Jacob,

On Wed, Sep 30, 2015 at 9:12 AM, Jacob Stiffler <j-stiffler@ti.com> wrote:
> The net_boot_file_name buffer is used as storage for the bootfilename
> command line argument to network boot commands such as tftp and nfs.
>
> Increase the size of this buffer to 1024 bytes as the current size of
> 128 bytes is restrictive for arbitrary paths on the server.
>
> Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Joe Hershberger Oct. 29, 2015, 7:33 p.m. UTC | #9
On Wed, Sep 30, 2015 at 9:12 AM, Jacob Stiffler <j-stiffler@ti.com> wrote:
> The net_boot_file_name buffer is used as storage for the bootfilename
> command line argument to network boot commands such as tftp and nfs.
>
> Increase the size of this buffer to 1024 bytes as the current size of
> 128 bytes is restrictive for arbitrary paths on the server.
>
> Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>

Applied to u-boot-net/master, thanks!
-Joe
diff mbox

Patch

diff --git a/include/net.h b/include/net.h
index f1671e3..197d2c6 100644
--- a/include/net.h
+++ b/include/net.h
@@ -512,7 +512,7 @@  enum proto_t {
 	TFTPSRV, TFTPPUT, LINKLOCAL
 };
 
-extern char	net_boot_file_name[128];/* Boot File name */
+extern char	net_boot_file_name[1024];/* Boot File name */
 /* The actual transferred size of the bootfile (in bytes) */
 extern u32	net_boot_file_size;
 /* Boot file size in blocks as reported by the DHCP server */
diff --git a/net/net.c b/net/net.c
index a115ce2..7116ef3 100644
--- a/net/net.c
+++ b/net/net.c
@@ -164,7 +164,7 @@  ushort		net_our_vlan = 0xFFFF;
 ushort		net_native_vlan = 0xFFFF;
 
 /* Boot File name */
-char net_boot_file_name[128];
+char net_boot_file_name[1024];
 /* The actual transferred size of the bootfile (in bytes) */
 u32 net_boot_file_size;
 /* Boot file size in blocks as reported by the DHCP server */