After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 681374 - g_seekable_seek() out-of-bounds behavior is inconsistent between implementations
g_seekable_seek() out-of-bounds behavior is inconsistent between implementations
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-08-07 13:17 UTC by Dan Winship
Modified: 2018-05-24 14:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gio: fix GLocalFileInputStream skip() behavior (5.11 KB, patch)
2012-08-07 13:17 UTC, Dan Winship
none Details | Review

Description Dan Winship 2012-08-07 13:17:46 UTC
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.
Comment 1 Dan Winship 2012-08-07 13:17:58 UTC
Created attachment 220552 [details] [review]
gio: fix GLocalFileInputStream skip() behavior

If you try to skip past the end of a stream, it's supposed to only
skip up to the end of the stream. But GLocalFileInputStream was not
doing this.

Fix up several problems in GInputStream's default seekable-based
skip() implementation, remove GLocalFileInputStream's now-unnecessary
implementation, and test that it works correctly from
gio/tests/readwrite.c.
Comment 2 Allison Karlitskaya (desrt) 2013-10-23 15:34:21 UTC
Note bug 684842.
Comment 3 GNOME Infrastructure Team 2018-05-24 14:27:23 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/587.