From 667bb3103d2ec7639f3ddf6b774273292d1a438c Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Mon, 23 Aug 2021 23:48:02 -0700 Subject: [PATCH] Fixed bug in edge case write() logic --- microstack/ILibProcessPipe.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/microstack/ILibProcessPipe.c b/microstack/ILibProcessPipe.c index 853fbd1..2bf1d34 100644 --- a/microstack/ILibProcessPipe.c +++ b/microstack/ILibProcessPipe.c @@ -1510,7 +1510,13 @@ ILibTransport_DoneState ILibProcessPipe_Pipe_Write(ILibProcessPipe_Pipe po, char if (result == TRUE) { retVal = ILibTransport_DoneState_COMPLETE; } #else int result = (int)write(pipeObject->mPipe_WriteEnd, buffer, bufferLen); - if (result > 0) { retVal = ILibTransport_DoneState_COMPLETE; } + while (result >= 0 && result < bufferLen) + { + buffer += result; + bufferLen -= result; + result = (int)write(pipeObject->mPipe_WriteEnd, buffer, bufferLen); + } + if (result == bufferLen) { retVal = ILibTransport_DoneState_COMPLETE; } #endif else {