g_input_stream_skip() out-of-bounds behavior is inconsistent between implementations
@danw
Submitted by Dan Winship Link to original bug (#681374)
Description
The g_seekable_seek() docs don't say what happens if you try to seek out of bounds.
Implementations like GMemory*Stream return G_IO_ERROR_INVALID_ARGUMENT if the resulting offset would be greater than the length of the stream. But the GLocalFile*Stream implementations just pass the value to lseek(), meaning if the offset is too large, it will just seek past the end of the file (potentially causing it to be extended in the GLocalFileOutputStream case).
g_local_file_input_stream_skip() also fails to take this behavior of lseek() into account, meaning that if you try to skip more bytes than are left in the file, you'll get a different result than if you try to read that many bytes (contradicting the g_input_stream_skip() docs).
A fix for that last part is attached.