Index: /trunk/include/iprt/stream.h
===================================================================
--- /trunk/include/iprt/stream.h	(revision 41503)
+++ /trunk/include/iprt/stream.h	(revision 41504)
@@ -223,14 +223,19 @@
 /**
  * Reads a line from a file stream.
- * A line ends with a '\\n', '\\0' or the end of the file.
- *
- * @returns iprt status code.
- * @returns VINF_BUFFER_OVERFLOW if the buffer wasn't big enough to read an entire line.
+ *
+ * A line ends with a '\\n', '\\r\\n', '\\0' or the end of the file.
+ *
+ * @returns iprt status code.
+ * @retval  VINF_BUFFER_OVERFLOW if the buffer wasn't big enough to read an
+ *          entire line.
+ * @retval  VERR_BUFFER_OVERFLOW if a lone '\\r' was encountered at the end of
+ *          the buffer and we ended up dropping the following character.
+ *
  * @param   pStream         The stream.
  * @param   pszString       Where to store the line.
  *                          The line will *NOT* contain any '\\n'.
- * @param   cchString       The size of the string buffer.
- */
-RTR3DECL(int) RTStrmGetLine(PRTSTREAM pStream, char *pszString, size_t cchString);
+ * @param   cbString        The size of the string buffer.
+ */
+RTR3DECL(int) RTStrmGetLine(PRTSTREAM pStream, char *pszString, size_t cbString);
 
 /**
Index: /trunk/src/VBox/Runtime/r3/stream.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/stream.cpp	(revision 41503)
+++ /trunk/src/VBox/Runtime/r3/stream.cpp	(revision 41504)
@@ -922,25 +922,14 @@
 
 
-/**
- * Reads a line from a file stream.
- * A line ends with a '\\n', '\\0' or the end of the file.
- *
- * @returns iprt status code.
- * @returns VINF_BUFFER_OVERFLOW if the buffer wasn't big enough to read an entire line.
- * @param   pStream         The stream.
- * @param   pszString       Where to store the line.
- *                          The line will *NOT* contain any '\\n'.
- * @param   cchString       The size of the string buffer.
- */
-RTR3DECL(int) RTStrmGetLine(PRTSTREAM pStream, char *pszString, size_t cchString)
+RTR3DECL(int) RTStrmGetLine(PRTSTREAM pStream, char *pszString, size_t cbString)
 {
     AssertReturn(RT_VALID_PTR(pStream) && pStream->u32Magic == RTSTREAM_MAGIC, VERR_INVALID_PARAMETER);
     int rc;
-    if (pszString && cchString > 1)
+    if (pszString && cbString > 1)
     {
         rc = pStream->i32Error;
         if (RT_SUCCESS(rc))
         {
-            cchString--;            /* save space for the terminator. */
+            cbString--;            /* save space for the terminator. */
             rtStrmLock(pStream);
             for (;;)
@@ -951,4 +940,27 @@
                 int ch = fgetc(pStream->pFile);
 #endif
+
+                /* Deal with \r\n sequences here. We'll return lone CR, but
+                   treat CRLF as LF. */
+                if (ch == '\r')
+                {
+#ifdef HAVE_FWRITE_UNLOCKED /** @todo darwin + freebsd(?) has fgetc_unlocked but not fwrite_unlocked, optimize... */
+                    ch = fgetc_unlocked(pStream->pFile);
+#else
+                    ch = fgetc(pStream->pFile);
+#endif
+                    if (ch == '\n')
+                        break;
+
+                    *pszString++ = '\r';
+                    if (--cbString <= 0)
+                    {
+                        /* yeah, this is an error, we dropped a character. */
+                        rc = VERR_BUFFER_OVERFLOW;
+                        break;
+                    }
+                }
+
+                /* Deal with end of file. */
                 if (ch == EOF)
                 {
@@ -975,8 +987,12 @@
                     break;
                 }
-                if (ch == '\0' || ch == '\n' || ch == '\r')
+
+                /* Deal with null terminator and (lone) new line. */
+                if (ch == '\0' || ch == '\n')
                     break;
+
+                /* No special character, append it to the return string. */
                 *pszString++ = ch;
-                if (--cchString <= 0)
+                if (--cbString <= 0)
                 {
                     rc = VINF_BUFFER_OVERFLOW;
