Fix QStorageInfo inability to parse really long mountinfo lines
Docker creates really long lines due to the multiple levels of overlays in the overlayfs. Our limit of 1024 bytes was too short. [ChangeLog][QtCore][QStorageInfo] Fixed a bug that caused QStorageInfo to be unable to report all filesystems if the options to mounted filesystems were too long (over 900 characters, roughly), such as those found in Docker overlay mounts. Fixes: QTBUG-77059 Change-Id: I6aed4df6a12e43c3ac8efffd15b1ba4231e60b4a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
c5ab86976b
commit
89e0c2854a
@ -468,8 +468,18 @@ inline bool QStorageIterator::next()
|
||||
size_t len = strlen(buffer.data());
|
||||
if (len == 0)
|
||||
return false;
|
||||
if (ptr[len - 1] == '\n')
|
||||
ptr[len - 1] = '\0';
|
||||
while (Q_UNLIKELY(ptr[len - 1] != '\n' && !feof(fp))) {
|
||||
// buffer wasn't large enough. Enlarge and try again.
|
||||
// (we're readidng from the kernel, so OOM is unlikely)
|
||||
buffer.resize((buffer.size() + 4096) & ~4095);
|
||||
ptr = buffer.data();
|
||||
if (fgets(ptr + len, buffer.size() - len, fp) == nullptr)
|
||||
return false;
|
||||
|
||||
len += strlen(ptr + len);
|
||||
Q_ASSERT(len < size_t(buffer.size()));
|
||||
}
|
||||
ptr[len - 1] = '\0';
|
||||
|
||||
// parse the line
|
||||
bool ok;
|
||||
|
Loading…
x
Reference in New Issue
Block a user