debug.h: Handle overflow in debug().

This commit is contained in:
Simon Ruderich
2013-06-03 04:32:12 +02:00
parent 686bf50bcd
commit 66fb589680

View File

@@ -33,6 +33,10 @@ static void debug(const char *format, ...) {
va_start(ap, format);
int written = vsnprintf(buffer, sizeof(buffer), format, ap);
va_end(ap);
/* Overflow. */
if ((size_t)written >= sizeof(buffer)) {
written = sizeof(buffer) - 1;
}
/* Make sure these functions are loaded. */
DLSYM_FUNCTION(real_write, "write");