]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/Stdio/fvwrite.c
StdLib: Fix issue with Canonical output expansion of NL to CR NL and similar expansions.
[mirror_edk2.git] / StdLib / LibC / Stdio / fvwrite.c
index 12773eff68e23470f1ac71ad36515c397feac711..feddc348c1ac05c537eb56672f9603f03921af25 100644 (file)
@@ -106,11 +106,12 @@ __sfvwrite(FILE *fp, struct __suio *uio)
       GETIOV(;);\r
       w = (*fp->_write)(fp->_cookie, p,\r
           (int)MIN(len, BUFSIZ));\r
-      if (w <= 0)\r
+      if (w < 0)\r
         goto err;\r
       p += w;\r
       len -= w;\r
-    } while ((uio->uio_resid -= w) != 0);\r
+    } while ((uio->uio_resid -= w) > 0);\r
+    uio->uio_resid = 0;   // Just in case it went negative such as when NL is expanded to CR NL\r
   } else if ((fp->_flags & __SLBF) == 0) {\r
     /*\r
      * Fully buffered: fill partially full buffer, if any,\r