VirtualBox

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


Ignore:
Timestamp:
Nov 27, 2023 5:50:21 PM (15 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
160476
Message:

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

Location:
trunk/src/libs/xpcom18a4
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/Makefile.kmk

    r102328 r102340  
    384384        nsprpub/lib/ds/plarena.c \
    385385        nsprpub/lib/ds/plhash.c \
    386         nsprpub/lib/libc/src/strcpy.c \
    387386        nsprpub/lib/libc/src/strcmp.c \
    388387        nsprpub/lib/libc/src/strccmp.c \
  • 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
  • trunk/src/libs/xpcom18a4/nsprpub/lib/libc/include/plstr.h

    r102323 r102340  
    7878PR_BEGIN_EXTERN_C
    7979/*
    80  * PL_strncpy
    81  *
    82  * Copies the source string into the destination buffer, up to and including
    83  * the trailing '\0' or up to and including the max'th character, whichever
    84  * comes first.  It does not (can not) verify that the destination buffer is
    85  * large enough.  If the source string is longer than the maximum length,
    86  * the result will *not* be null-terminated (JLRU).
    87  */
    88 
    89 PR_EXTERN(char *)
    90 PL_strncpy(char *dest, const char *src, PRUint32 max);
    91 
    92 /*
    93  * PL_strncpyz
    94  *
    95  * Copies the source string into the destination buffer, up to and including
    96  * the trailing '\0' or up but not including the max'th character, whichever
    97  * comes first.  It does not (can not) verify that the destination buffer is
    98  * large enough.  The destination string is always terminated with a '\0',
    99  * unlike the traditional libc implementation.  It returns the "dest" argument.
    100  *
    101  * NOTE: If you call this with a source "abcdefg" and a max of 5, the
    102  * destination will end up with "abcd\0" (i.e., it's strlen length will be 4)!
    103  *
    104  * This means you can do this:
    105  *
    106  *     char buffer[ SOME_SIZE ];
    107  *     PL_strncpyz(buffer, src, sizeof(buffer));
    108  *
    109  * and the result will be properly terminated.
    110  */
    111 
    112 PR_EXTERN(char *)
    113 PL_strncpyz(char *dest, const char *src, PRUint32 max);
    114 
    115 /*
    11680 * PL_strcmp
    11781 *
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