VirtualBox

Changeset 102340 in vbox for trunk/src/libs/xpcom18a4/ipc


Ignore:
Timestamp:
Nov 27, 2023 5:50:21 PM (14 months ago)
Author:
vboxsync
Message:

libs/xpcom: Replace the uses of PL_strncpyz with RTStrCopyPand get rid of it, bugref:10545

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcConfig.cpp

    r102249 r102340  
    3737#define LOG_GROUP LOG_GROUP_IPC
    3838
    39 #if defined(XP_WIN)
    40 #elif defined(XP_OS2) && defined(XP_OS2_NATIVEIPC)
    41 #else
    42 #include <string.h>
    43 #ifdef XP_UNIX
    4439#include <unistd.h>
    4540#include <sys/types.h>
    4641#include <pwd.h>
    47 #endif
     42
    4843#include "ipcConfig.h"
    49 #include "plstr.h"
    5044
    5145#include <iprt/env.h>
     46#include <iprt/string.h>
    5247#include <VBox/log.h>
    5348
    54 #if defined(XP_OS2) && !defined(XP_OS2_NATIVEIPC)
    55 #ifdef VBOX
    56 static const char kDefaultSocketPrefix[] = "\\socket\\vbox-";
    57 #else
    58 static const char kDefaultSocketPrefix[] = "\\socket\\mozilla-";
    59 #endif
    60 static const char kDefaultSocketSuffix[] = "-ipc\\ipcd";
    61 #else
    62 #ifdef VBOX
    6349static const char kDefaultSocketPrefix[] = "/tmp/.vbox-";
    64 #else
    65 static const char kDefaultSocketPrefix[] = "/tmp/.mozilla-";
    66 #endif
    6750static const char kDefaultSocketSuffix[] = "-ipc/ipcd";
    68 #endif
    6951
    7052void IPC_GetDefaultSocketPath(char *buf, PRUint32 bufLen)
     
    7355    int len;
    7456
    75     PL_strncpyz(buf, kDefaultSocketPrefix, bufLen);
    76     buf    += (sizeof(kDefaultSocketPrefix) - 1);
    77     bufLen -= (sizeof(kDefaultSocketPrefix) - 1);
     57    char *pszDst = buf;
     58    size_t cbDst = bufLen;
     59    int vrc = RTStrCopyP(&pszDst, &cbDst, kDefaultSocketPrefix);
     60    AssertRC(vrc); RT_NOREF(vrc);
    7861
    7962    logName = RTEnvGet("VBOX_IPC_SOCKETID");
    80 #if defined(VBOX) && defined(XP_UNIX)
    8163    if (!logName || !logName[0]) {
    8264        struct passwd *passStruct = getpwuid(getuid());
     
    8466            logName = passStruct->pw_name;
    8567    }
    86 #endif
     68
    8769    if (!logName || !logName[0]) {
    8870        logName = RTEnvGet("LOGNAME");
     
    9577        }
    9678    }
    97     PL_strncpyz(buf, logName, bufLen);
    98     len = strlen(logName);
    99     buf    += len;
    100     bufLen -= len;
     79
     80    vrc = RTStrCopyP(&pszDst, &cbDst, logName);
     81    AssertRC(vrc); RT_NOREF(vrc);
    10182
    10283end:
    103     PL_strncpyz(buf, kDefaultSocketSuffix, bufLen);
     84    vrc = RTStrCopyP(&pszDst, &cbDst, kDefaultSocketSuffix);
     85    AssertRC(vrc); RT_NOREF(vrc);
    10486}
    105 
    106 #endif
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette