]> git.ipfire.org Git - thirdparty/grub.git/commit
net/tftp: Fix stack buffer overflow in tftp_open()
authorB Horn <b@horn.uk>
Thu, 18 Apr 2024 16:32:34 +0000 (17:32 +0100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 13 Feb 2025 14:45:55 +0000 (15:45 +0100)
commit0707accab1b9be5d3645d4700dde3f99209f9367
tree68b1cef23ec555270a44521c74734e042b2e2ec0
parent5eef88152833062a3f7e017535372d64ac8ef7e1
net/tftp: Fix stack buffer overflow in tftp_open()

An overly long filename can be passed to tftp_open() which would cause
grub_normalize_filename() to write out of bounds.

Fixed by adding an extra argument to grub_normalize_filename() for the
space available, making it act closer to a strlcpy(). As several fixed
strings are strcpy()'d after into the same buffer, their total length is
checked to see if they exceed the remaining space in the buffer. If so,
return an error.

On the occasion simplify code a bit by removing unneeded rrqlen zeroing.

Reported-by: B Horn <b@horn.uk>
Signed-off-by: B Horn <b@horn.uk>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/net/tftp.c