[Libreoffice-commits] .: 2 commits - cppuhelper/source sal/osl

David Tardon dtardon at kemper.freedesktop.org
Mon May 16 06:44:58 PDT 2011


 cppuhelper/source/component_context.cxx |    1 
 sal/osl/unx/pipe.c                      |   37 +++++++++++++++++++++++---------
 2 files changed, 28 insertions(+), 10 deletions(-)

New commits:
commit 6fd63a0ddbf28e2490f195837ebef56f6d4121c1
Author: David Tardon <dtardon at redhat.com>
Date:   Mon May 16 10:28:03 2011 +0200

    delete[] after use

diff --git a/cppuhelper/source/component_context.cxx b/cppuhelper/source/component_context.cxx
index 60e039b..59851cc 100644
--- a/cppuhelper/source/component_context.cxx
+++ b/cppuhelper/source/component_context.cxx
@@ -892,6 +892,7 @@ Reference< XComponentContext > SAL_CALL createComponentContext(
     void * mapped_delegate = curr2source.mapInterface(xDelegate.get(), ::getCppuType(&xDelegate));
     XComponentContext * pXComponentContext = NULL;
     source_env.invoke(s_createComponentContext_v, mapped_entries, nEntries, mapped_delegate, &pXComponentContext, &source2curr);
+    delete[] mapped_entries;
 
     return Reference<XComponentContext>(pXComponentContext, SAL_NO_ACQUIRE);
 }
commit b5c6345bb452c0a814aefe06bc5d215ad089397d
Author: David Tardon <dtardon at redhat.com>
Date:   Mon May 16 09:18:53 2011 +0200

    make this more robust

diff --git a/sal/osl/unx/pipe.c b/sal/osl/unx/pipe.c
index 38a1413..6309e73 100644
--- a/sal/osl/unx/pipe.c
+++ b/sal/osl/unx/pipe.c
@@ -166,6 +166,8 @@ oslPipe SAL_CALL osl_psz_createPipe(const sal_Char *pszPipeName, oslPipeOptions
     struct sockaddr_un addr;
 
     sal_Char  	 name[PATH_MAX + 1];
+    size_t nNameLength = 0;
+    int bNameTooLong = 0;
     oslPipe  pPipe;
 
     if (access(PIPEDEFAULTPATH, R_OK|W_OK) == 0)
@@ -176,26 +178,41 @@ oslPipe SAL_CALL osl_psz_createPipe(const sal_Char *pszPipeName, oslPipeOptions
     {
         strncpy(name, PIPEALTERNATEPATH, sizeof(name));
     }
+    name[sizeof(name) - 1] = '\0';  // ensure the string is NULL-terminated
+    nNameLength = strlen(name);
+    bNameTooLong = nNameLength > sizeof(name) - 2;
 
+    if (!bNameTooLong)
+    {
+        size_t nRealLength = 0;
 
-    strncat(name, "/", sizeof(name));
+        strcat(name, "/");
+        ++nNameLength;
 
-    if (Security)
-    {
-        sal_Char Ident[256];
+        if (Security)
+        {
+            sal_Char Ident[256];
 
-        Ident[0] = '\0';
+            Ident[0] = '\0';
 
-        OSL_VERIFY(osl_psz_getUserIdent(Security, Ident, sizeof(Ident)));
+            OSL_VERIFY(osl_psz_getUserIdent(Security, Ident, sizeof(Ident)));
 
-        snprintf(&name[strlen(name)], sizeof(name), SECPIPENAMEMASK, Ident, pszPipeName);
+            nRealLength = snprintf(&name[nNameLength], sizeof(name) - nNameLength, SECPIPENAMEMASK, Ident, pszPipeName);
+        }
+        else
+        {
+            nRealLength = snprintf(&name[nNameLength], sizeof(name) - nNameLength, PIPENAMEMASK, pszPipeName);
+        }
+
+        bNameTooLong = nRealLength > sizeof(name) - nNameLength - 1;
     }
-    else
+
+    if (bNameTooLong)
     {
-        snprintf(&name[strlen(name)], sizeof(name), PIPENAMEMASK, pszPipeName);
+        OSL_TRACE("osl_createPipe: pipe name too long");
+        return NULL;
     }
 
-
     /* alloc memory */
     pPipe= __osl_createPipeImpl();
 


More information about the Libreoffice-commits mailing list