Skip at most the length of the buffer

The skip: method contains an assert that triggers if the skip length is
larger than the size of the buffer. This is not ideal and an exception
is probably more appropriate. It's however not really critical so we can
get around it by just checking if the length exceeds the length of the
buffer, and adjust it if needed. That way we won't attempt to skip more
than what the buffer holds.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>