VirtualBox

Changeset 103444 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Feb 19, 2024 1:58:17 PM (11 months ago)
Author:
vboxsync
Message:

IPRT: Reverted r161541, r161577 & r161578 because the RTStrCopy2 and RTStrCat2 functions encourages writing unsafe code, given that RTStrCat[2] doesn't check for NULL destination buffers and will crash if the two are chained.

Location:
trunk/src/VBox/Runtime/common/string
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/RTStrCat.cpp

    r103284 r103444  
    4545
    4646
    47 DECLINLINE(int) rtStrCat(char *pszDst, size_t cbDst, const char *pszSrc)
     47RTDECL(int) RTStrCat(char *pszDst, size_t cbDst, const char *pszSrc)
    4848{
    4949    char *pszDst2 = RTStrEnd(pszDst, cbDst);
     
    6565    return VERR_BUFFER_OVERFLOW;
    6666}
    67 
    68 RTDECL(int) RTStrCat(char *pszDst, size_t cbDst, const char *pszSrc)
    69 {
    70     return rtStrCat(pszDst, cbDst, pszSrc);
    71 }
    7267RT_EXPORT_SYMBOL(RTStrCat);
    7368
    74 RTDECL(char *) RTStrCat2(char *pszDst, size_t cbDst, const char *pszSrc)
    75 {
    76     return RT_SUCCESS(rtStrCat(pszDst, cbDst, pszSrc)) ? pszDst : NULL;
    77 }
    78 RT_EXPORT_SYMBOL(RTStrCat2);
    79 
  • trunk/src/VBox/Runtime/common/string/RTStrCopy.cpp

    r103252 r103444  
    4545
    4646
    47 DECLINLINE(int) rtStrCopy(char *pszDst, size_t cbDst, const char *pszSrc)
     47RTDECL(int) RTStrCopy(char *pszDst, size_t cbDst, const char *pszSrc)
    4848{
    4949    size_t cchSrc = strlen(pszSrc);
     
    6161    return VERR_BUFFER_OVERFLOW;
    6262}
    63 
    64 RTDECL(int) RTStrCopy(char *pszDst, size_t cbDst, const char *pszSrc)
    65 {
    66     return rtStrCopy(pszDst, cbDst, pszSrc);
    67 }
    6863RT_EXPORT_SYMBOL(RTStrCopy);
    6964
    70 RTDECL(char *) RTStrCopy2(char *pszDst, size_t cbDst, const char *pszSrc)
    71 {
    72     return RT_SUCCESS(rtStrCopy(pszDst, cbDst, pszSrc)) ? pszDst : NULL;
    73 }
    74 RT_EXPORT_SYMBOL(RTStrCopy2);
    75 
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