Fix buffer_getchar to only error if we'd exceed the buffer size