Index: /trunk/include/iprt/cpp/ministring.h
===================================================================
--- /trunk/include/iprt/cpp/ministring.h	(revision 33861)
+++ /trunk/include/iprt/cpp/ministring.h	(revision 33862)
@@ -102,12 +102,19 @@
      * Create a partial copy of another MiniString.
      *
+     * @param   a_rSrc          The source string.
+     * @param   a_offSrc        The byte offset into the source string.
      * @param   a_cchSrc        The max number of chars (encoded UTF-8 bytes)
      *                          to copy from the source string.
-     * @param   a_rSrc          The source string.
-     */
-    MiniString(size_t a_cchSrc, const MiniString &a_rSrc)
-    {
-        Assert(a_cchSrc <= a_rSrc.m_cch);
-        copyFromN(a_rSrc.m_psz, RT_MIN(a_cchSrc, a_rSrc.m_cch));
+     */
+    MiniString(const MiniString &a_rSrc, size_t a_offSrc, size_t a_cchSrc = npos)
+    {
+        if (a_offSrc < a_rSrc.m_cch)
+            copyFromN(&a_rSrc.m_psz[a_offSrc], RT_MIN(a_cchSrc, a_rSrc.m_cch - a_offSrc));
+        else
+        {
+            m_psz = NULL;
+            m_cch = 0;
+            m_cbAllocated = 0;
+        }
     }
 
@@ -115,13 +122,36 @@
      * Create a partial copy of a C string.
      *
+     * @param   a_pszSrc        The source string (UTF-8).
      * @param   a_cchSrc        The max number of chars (encoded UTF-8 bytes)
-     *                          to copy from the source string.
-     * @param   a_pszSrc        The source string (UTF-8).
-     */
-    MiniString(size_t a_cchSrc, const char *a_pszSrc)
+     *                          to copy from the source string.  This must not
+     *                          be '0' as the compiler could easily mistake
+     *                          that for the va_list constructor.
+     */
+    MiniString(const char *a_pszSrc, size_t a_cchSrc)
     {
         size_t cchMax = a_pszSrc ? RTStrNLen(a_pszSrc, a_cchSrc) : 0;
-        Assert(a_cchSrc <= cchMax);
         copyFromN(a_pszSrc, RT_MIN(a_cchSrc, cchMax));
+    }
+
+    /**
+     * Create a string containing @a a_cTimes repetitions of the character @a
+     * a_ch.
+     *
+     * @param   a_cTimes        The number of times the character is repeated.
+     * @param   a_ch            The character to fill the string with.
+     */
+    MiniString(size_t a_cTimes, char a_ch)
+        : m_psz(NULL),
+          m_cch(0),
+          m_cbAllocated(0)
+    {
+        Assert((unsigned)a_ch < 0x80);
+        if (a_cTimes)
+        {
+            reserve(a_cTimes + 1);
+            memset(m_psz, a_ch, a_cTimes);
+            m_psz[a_cTimes] = '\0';
+            m_cch = a_cTimes;
+        }
     }
 
@@ -134,4 +164,5 @@
      *                          specified by the format string.
      * @sa      printfV
+     * @remarks Not part of std::string.
      */
     MiniString(const char *a_pszFormat, va_list a_va)
@@ -139,5 +170,4 @@
           m_cch(0),
           m_cbAllocated(0)
-
     {
         printfV(a_pszFormat, a_va);
@@ -783,5 +813,6 @@
                 m_cch = cchSrc;
                 m_cbAllocated = cchSrc + 1;
-                memcpy(m_psz, pcszSrc, cchSrc + 1);
+                memcpy(m_psz, pcszSrc, cchSrc);
+                m_psz[cchSrc] = '\0';
             }
             else
Index: /trunk/src/VBox/Main/ExtPackUtil.cpp
===================================================================
--- /trunk/src/VBox/Main/ExtPackUtil.cpp	(revision 33861)
+++ /trunk/src/VBox/Main/ExtPackUtil.cpp	(revision 33862)
@@ -180,5 +180,5 @@
      * Make a duplicate of the name and return it.
      */
-    iprt::MiniString *pStrRet = new iprt::MiniString(off, pszSrc);
+    iprt::MiniString *pStrRet = new iprt::MiniString(pszSrc, off);
     Assert(VBoxExtPackIsValidName(pStrRet->c_str()));
     return pStrRet;
Index: /trunk/src/VBox/Runtime/testcase/tstIprtMiniString.cpp
===================================================================
--- /trunk/src/VBox/Runtime/testcase/tstIprtMiniString.cpp	(revision 33861)
+++ /trunk/src/VBox/Runtime/testcase/tstIprtMiniString.cpp	(revision 33862)
@@ -39,4 +39,5 @@
 static void test1Hlp1(const char *pszExpect, const char *pszFormat, ...)
 {
+#if 0
     va_list va;
     va_start(va, pszFormat);
@@ -44,4 +45,5 @@
     va_end(va);
     RTTESTI_CHECK_MSG(strTst.equals(pszExpect),  ("strTst='%s' expected='%s'\n",  strTst.c_str(), pszExpect));
+#endif
 }
 
@@ -61,4 +63,9 @@
         if (!(expr)) \
             RTTestFailed(hTest, "%d: FAILED %s, got \"%d\"", __LINE__, #expr, expr); \
+    } while (0)
+#define CHECK_EQUAL(Str, szExpect) \
+    do { \
+        if (!(Str).equals(szExpect)) \
+            RTTestIFailed("line %u: expected \"%s\" got \"%s\"", __LINE__, szExpect, (Str).c_str()); \
     } while (0)
 
@@ -167,4 +174,42 @@
     test1Hlp1("foobar", "%s", "foobar");
 
+    /* substring constructors */
+    iprt::MiniString SubStr1("", (size_t)0);
+    CHECK_EQUAL(SubStr1, "");
+
+    iprt::MiniString SubStr2("abcdef", 2);
+    CHECK_EQUAL(SubStr2, "ab");
+
+    iprt::MiniString SubStr3("abcdef", 1);
+    CHECK_EQUAL(SubStr3, "a");
+
+    iprt::MiniString SubStr4("abcdef", 6);
+    CHECK_EQUAL(SubStr4, "abcdef");
+
+    iprt::MiniString SubStr5("abcdef", 7);
+    CHECK_EQUAL(SubStr5, "abcdef");
+
+
+    iprt::MiniString SubStrBase("abcdef");
+
+    iprt::MiniString SubStr10(SubStrBase, 0);
+    CHECK_EQUAL(SubStr10, "abcdef");
+
+    iprt::MiniString SubStr11(SubStrBase, 1);
+    CHECK_EQUAL(SubStr11, "bcdef");
+
+    iprt::MiniString SubStr12(SubStrBase, 1, 1);
+    CHECK_EQUAL(SubStr12, "b");
+
+    iprt::MiniString SubStr13(SubStrBase, 2, 3);
+    CHECK_EQUAL(SubStr13, "cde");
+
+    iprt::MiniString SubStr14(SubStrBase, 2, 4);
+    CHECK_EQUAL(SubStr14, "cdef");
+
+    iprt::MiniString SubStr15(SubStrBase, 2, 5);
+    CHECK_EQUAL(SubStr15, "cdef");
+
+
     /* special constructor and assignment arguments */
     iprt::MiniString StrCtor1("");
@@ -211,4 +256,5 @@
 #undef CHECK_DUMP
 #undef CHECK_DUMP_I
+#undef CHECK_EQUAL
 }
 
