fix off-by-one in grub_file_getline
PATCH 1/1 fix off-by-one in grub_file_getline
I'd like to submit a few trivial patches that I've had on my hard drive for a while. This patch is against the latest version in the trunk on bzr.savannah.gnu.org.
If grub_file_getline tries to read a line which is exactly 64 bytes long it will write the terminating zero past the end of the allocated buffer causing memory corruption.
Trivial fix which reserves one more byte in the buffer.
grub-core/normal/main.c +1 -1
@@ -65,7 +65,7 @@ grub_file_getline (grub_file_t file)continue ; -if (pos >= max_len) +if (pos +1 >= max_len) {char *old_cmdline = cmdline; max_len = max_len *2 ;
Signature · 4 lines
Have laptop, will travel. I'm a consultant looking for interesting jobs anywhere in the world. I'm an experienced software engineer with a solid understanding of hardware. Specialities: Linux, device drivers and embedded systems in general. Find me at www.weinigel.se.
Committed, thanks. Could you supply ChangeLog entry next time?
Quoted 24 lines · Christer Weinigel
I'd like to submit a few trivial patches that I've had on my hard drive for a while. This patch is against the latest version in the trunk on bzr.savannah.gnu.org.
If
grub_file_getlinetries to read a line which is exactly 64 bytes long it will write the terminating zero past the end of the allocated buffer causing memory corruption.Trivial fix which reserves one more byte in the buffer.
grub-core/normal/main.c +1
-1@@ -65,7 +65,7 @@ grub_file_getline (grub_file_t file)continue ; -if (pos >= max_len) +if (pos +1 >= max_len) {char *old_cmdline = cmdline; max_len = max_len *2 ;
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko