Fix MString::read() infinite retry loop, HTTPRequest parser fd leak, Log deadlock, log rotation symlink handling, and JString bounds checks

- MString::read() now gives up after repeated I/O errors instead of
  looping forever and crashing via realloc() failure (root cause of a
  recurring barant.com production crash).
- HTTPRequest::parse() no longer leaks lineParser/headerParser on a
  malformed request.
- Log gained size-based rotation (config-driven) and a non-static-mutex
  fix; a separate fix stopped rotation from destroying the logs symlink
  on its first trigger.
- File.cpp: symlink-preserving rotation support.
- JString: fixed an array-index out-of-bounds and a setString issue.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Brad ArantandClaude Sonnet 5 committed 2026-10-06 17:38:14 +00:00
1 parent 694c6b80a4
commit 05374bdb15
7 files changed
+213 -14

No files matched your search

+23
View File
@@ -29,11 +29,34 @@ namespace coreutils {
size_t size;
bool eof();
///
/// Real, on-disk size of this file right now, queried directly
/// from the OS via fstat() - not the "size" member above, which
/// is only ever set at open()/read() time and goes stale the
/// moment anything else appends to this fd (exactly the case for
/// a long-lived, append-mode file such as Log's static logFile).
///
size_t currentSize();
///
/// Close this file, shift any existing ".1" .. ".maxBackups-1"
/// backups up by one (deleting whatever already sits at
/// ".maxBackups"), rename the current file to ".1", then reopen
/// a fresh file at the original path/mode/authority. Meant for a
/// long-lived, append-mode file that needs a size cap - not
/// meaningful for a file opened for reading.
///
void rotate(int maxBackups);
coreutils::ZString fileName;
private:
void open(coreutils::ZString fileName, int mode, int authority);
int fd;
int mode;
int authority;
coreutils::ZString zstring;
bool mEof = false;