Fix input buffer overrun