GNOME Bugzilla – Bug 738956
Potential offset overflow on 32-bit
Last modified: 2021-06-10 14:57:45 UTC
VTE uses gsize for the ever-increasing logical byte offset in the ring/stream/etc. This overflows after printing ~25M lines of 80 characters which is not an unreasonably extreme scenario, vte can process this much data in about 15 minutes. Buggy behavior is bound to happen (although I haven't tested) both in memory, and in the scrollback file with infinite scrollback. We should #define _FILE_OFFSET_BITS 64, s/gsize/off_t, s/fseek/fseeko, maybe some compiletime/runtime assertions on these sizes -- what else? Preferably not just for byte offsets but also for line offsets (insert_delta/scroll_delta etc.).
Can we do it without API implications? I fully support an easy define somewhere!
s/gsize/off_t should be selective (not a blind #define or search-n-replace, but only where the semantics is file offset). #define _FILE_OFFSET_BITS 64 and s/fseek/fseeko are probably easy bits, although I don't know how they'd influence non-Linux systems. What API do you think of? I think we don't rely on glib for such file operations, only on glibc, where apparently the magic is hidden for us (probably fwrite() and friends map to a different call if _FILE_OFFSET_BITS==64, not sure how else it could take varying width arguments, but that's not our business, it's already done). I don't think vte's API would need to be changed. I'm not sure about any of these, though :) IMO the tough part is finding a 32-bit test machine (I don't have any) or bringing up a VM or figuring out how to build against 32-bit libs (and hoping that's the same), then coming up with a reproducible test case, maybe saving that 15 minutes every time by manually seeking to almost 2^31 or 2^32 (I'm not even sure which)...
BTW I'm not even sure this bug is worth addressing. Do we know how many computers that run gnome-terminal are 32 vs. 64-bit and what's the trend? Are 32-bit computer going to die out in a few years, or will they live long (in tablets, OLPC etc.)? This bug is likely hit by power users only, I doubt many of them are still stuck with 32-bits. I don't know.
Yes, I think since we got away with it till now, we might as well ignore it.
-- 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/vte/-/issues/2140.