From 3f0a541e807c9be98868b5404d88638aff221199 Mon Sep 17 00:00:00 2001 From: brad Arant Date: Fri, 14 Feb 2025 11:56:11 -0800 Subject: [PATCH] added byte count limiter for read on MString. --- MString.cpp | 7 +++++++ MString.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/MString.cpp b/MString.cpp index 31610b2..73fa121 100644 --- a/MString.cpp +++ b/MString.cpp @@ -278,6 +278,13 @@ namespace coreutils { write(ch); return *this; } + + MString &MString::read(int fd, int count) { + char ch; + while(count-- && ::read(fd, &ch, 1)) + write(ch); + return *this; + } int MString::offset() { return cursor - data; diff --git a/MString.h b/MString.h index c0fde6d..46f90df 100644 --- a/MString.h +++ b/MString.h @@ -231,7 +231,8 @@ namespace coreutils { /// MString &read(int fd); - + MString &read(int fd, int len); + /// /// ///