VirtualBox

Changeset 103343 in vbox


Ignore:
Timestamp:
Feb 14, 2024 1:55:23 AM (10 months ago)
Author:
vboxsync
Message:

IPRT/fdt.cpp: If you do strlen already, use memcpy instead of strcpy. cbStr always includes the terminator. pb would imply uint8_t pointer, not char pointer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/fdt.cpp

    r103342 r103343  
    17081708    *pu32++ = RT_H2BE_U32(offStr);
    17091709
    1710     char *pb = (char *)pu32;
     1710    char *pchDst = (char *)pu32;
    17111711    for (uint32_t i = 0; i < cStrings; i++)
    17121712    {
    1713         const char *psz = va_arg(va, const char *);
    1714         /* MSVC doesn't know about stpcpy(), so we have to query the string length again... */
    1715         uint32_t cbStr = (uint32_t)strlen(psz);
    1716         strcpy(pb, psz);
    1717         pb += cbStr + 1;
     1713        const char * const pszSrc = va_arg(va, const char *);
     1714        size_t const cbStr = strlen(pszSrc) + 1;
     1715        Assert((size_t)(pchDst - (char *)pu32) >= cbStr);
     1716        memcpy(pchDst, pszSrc, cbStr);
     1717        pchDst += cbStr;
    17181718    }
    17191719
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