diff options
| author | saturneric <[email protected]> | 2026-09-12 23:54:02 +0200 |
|---|---|---|
| committer | saturneric <[email protected]> | 2026-09-12 23:54:02 +0200 |
| commit | c47bcd1eb3ef0167ba6f109c0fd33e0afcc1774b (patch) | |
| tree | 16c2562b41e9d40bbd101401d746738cf45decce /src | |
| parent | fix(email): secure password and probe cleanup (diff) | |
| download | modules-c47bcd1eb3ef0167ba6f109c0fd33e0afcc1774b.tar.gz modules-c47bcd1eb3ef0167ba6f109c0fd33e0afcc1774b.zip | |
fix(email): reject non-regular and oversized files
- prevent FIFOs, device nodes, and proc entries from blocking readAll()
- recheck the opened file size to handle path races and size changes
- keep oversized message files from being loaded on the GUI thread
Diffstat (limited to 'src')
| -rw-r--r-- | src/m_email/EMailModule.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/m_email/EMailModule.cpp b/src/m_email/EMailModule.cpp index 9beabae..ef8e4ff 100644 --- a/src/m_email/EMailModule.cpp +++ b/src/m_email/EMailModule.cpp @@ -1937,6 +1937,20 @@ REGISTER_EVENT_HANDLER( // parse of untrusted input, and that is now bounded properly by the // depth, part-count and decoded-size limits in ExtractParts -- so the // ceiling can be about memory alone. + // A FIFO, a device node or /proc entry reports size 0 and would sail + // through the ceiling below, then block or grow without bound inside + // readAll() -- on the GUI thread, where the read actually happens. + if (!file_info.isFile()) { + QMessageBox::warning( + nullptr, QApplication::translate("EMailModule", "Warning"), + QApplication::translate( + "EMailModule", + "%1 is not an ordinary file, so it cannot be opened as a " + "message.") + .arg(file_path)); + CB_ERR(event, -1, "not a regular file"); + } + if (file_info.size() > kMaxEMLFileSize) { QMessageBox::warning( nullptr, QApplication::translate("EMailModule", "Warning"), @@ -1980,6 +1994,23 @@ REGISTER_EVENT_HANDLER( return; } + // Checked again on the OPEN handle. The size test above ran on the + // module thread against a path; this runs against the file actually + // opened, which is not necessarily the same one and not necessarily + // the same length. + if (file.size() > kMaxEMLFileSize) { + QMessageBox::warning( + nullptr, QApplication::translate("EMailModule", "Warning"), + QApplication::translate( + "EMailModule", + "The file %1 is too large (%2) to be opened. The maximum " + "allowed size is %3.") + .arg(file_path) + .arg(QLocale().formattedDataSize(file.size())) + .arg(QLocale().formattedDataSize(kMaxEMLFileSize))); + return; + } + QWidget* page = nullptr; auto ok = QMetaObject::invokeMethod( |
