Skip to content
Commit 20281ac1 authored by Niko Tsirakis's avatar Niko Tsirakis Committed by Chromium LUCI CQ
Browse files

[chromebox_for_meetings] Don't drop characters from lines

The GetCurrentOffset() function was written to support
getting the current file offset, even if the file is at
an EOF, which would normally cause tellg() to return -1.
To handle the EOF case, we were performing the following
routine: clear EOF bit -> tellg() -> .get() to re-trigger
the EOF bit. It was falsely determined that the .get()
call would be safe and not advance the read pointer, but
in very specific cases, this causes some log lines to have
their leading character dropped, which leads to a malformed
timestamp and effectively drops the log.

Instead of this hacky process, we can track the last known
read offset in a member variable and treat it as the current
offset when we've reached an EOF. This logic works because
tellg() will only report a -1 *after* we attempt a read that
contains no data; if we call tellg() after reading the last
line, but before calling getline() again, it will report the
correct offset.

Bug: b:343965002
Change-Id: Icd43161c3c1114302c88b1fbc151198be05674f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5589844


Auto-Submit: Niko Tsirakis <ntsirakis@google.com>
Reviewed-by: default avatarKyle Williams <kdgwill@chromium.org>
Commit-Queue: Kyle Williams <kdgwill@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1310785}
parent 7394c099
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment