mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-04-18 17:07:02 +02:00
libc: fix a pointer overflow in kprint
When the size of the input buffer is not specified, the default was INT_MAX; however this will cause the pointer value to overflow in many situations, causing kprint_flush() to flush prematurely and write NUL bytes at inappropriate places. This commit changes the default size to 65535. Morale: never use sprintf() or vsprintf()...
This commit is contained in:
parent
ff2db385a8
commit
1685813078
1 changed files with 2 additions and 3 deletions
|
@ -15,7 +15,6 @@
|
||||||
#include <gint/defs/util.h>
|
#include <gint/defs/util.h>
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
//---
|
//---
|
||||||
// kprint() definitions
|
// kprint() definitions
|
||||||
|
@ -565,7 +564,7 @@ GWEAK int sprintf(char *str, char const *format, ...)
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
|
|
||||||
int count = kvsprint(str, INT_MAX, format, &args);
|
int count = kvsprint(str, 65536, format, &args);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return count;
|
return count;
|
||||||
|
@ -574,7 +573,7 @@ GWEAK int sprintf(char *str, char const *format, ...)
|
||||||
/* vsprintf() */
|
/* vsprintf() */
|
||||||
GWEAK int vsprintf(char *str, char const *format, va_list args)
|
GWEAK int vsprintf(char *str, char const *format, va_list args)
|
||||||
{
|
{
|
||||||
return kvsprint(str, INT_MAX, format, &args);
|
return kvsprint(str, 65536, format, &args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* snprintf() */
|
/* snprintf() */
|
||||||
|
|
Loading…
Add table
Reference in a new issue