mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zipl/libc: Fix potential buffer overflow in printf
Per definition vsprint assumes that the provided buffer it writes to is large enough to contain the formatted string. As printf uses a fixed sized buffer (81 bytes) and has no size checks the use of vsprintf can easily cause buffer overflows. Protect against these buffer overflows by using vsnprintf instead. While at it fix a typo in the comment. Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Philipp Rudo <prudo@linux.ibm.com> Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com> Reviewed-by: Stefan Haberland <sth@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
6fe9e6c55c
commit
8874b90825
@@ -532,7 +532,7 @@ void sprintf(char *str, const char *fmt, ...)
|
||||
}
|
||||
|
||||
/*
|
||||
* Print formated string
|
||||
* Print formatted string to console
|
||||
*/
|
||||
void printf(const char *fmt, ...)
|
||||
{
|
||||
@@ -540,7 +540,7 @@ void printf(const char *fmt, ...)
|
||||
va_list va;
|
||||
|
||||
va_start(va, fmt);
|
||||
vsprintf(buf, fmt, va);
|
||||
vsnprintf(buf, sizeof(buf), fmt, va);
|
||||
sclp_print(buf);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user