VirtualBox

Changeset 98104 in vbox


Ignore:
Timestamp:
Jan 17, 2023 2:47:49 PM (23 months ago)
Author:
vboxsync
Message:

IPRT/RTTimeZoneGetCurrent-posix.cpp: Skip quoting before uinsg ZONE variable from /etc/sysconfig/clock.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/RTTimeZoneGetCurrent-posix.cpp

    r98103 r98104  
    8080 *                              <tzfile.h>:TZDIR (normally /usr/share/zoneinfo),
    8181 *                              e.g. Europe/London, or Etc/UTC, or UTC, or etc.
     82 *
     83 * @note    File format is documented in RFC-8536.
    8284 */
    8385static int rtIsValidTimeZoneFile(const char *pszTimeZone)
     
    218220     * Older versions of RedHat / OEL don't have /etc/localtime as a symlink or
    219221     * /etc/timezone but instead have /etc/sysconfig/clock which contains a line
    220      * of the syntax ZONE=Europe/London amongst other entries.
     222     * of the syntax ZONE=Europe/London or ZONE="Europe/London" amongst other entries.
    221223     */
    222224    pszPath = PATH_SYSCONFIG_CLOCK;
     
    230232            {
    231233                static char const s_szVarEq[] = "ZONE=";
    232                 if (memcmp(szBuf, RT_STR_TUPLE(s_szVarEq)) == 0)
     234                char             *pszStart    = RTStrStrip(szBuf);
     235                if (memcmp(pszStart, RT_STR_TUPLE(s_szVarEq)) == 0)
    233236                {
    234                     const char *pszTimeZone = &szBuf[sizeof(s_szVarEq) - 1];
     237                    char *pszTimeZone = &pszStart[sizeof(s_szVarEq) - 1];
     238
     239                    /* Drop any quoting before using the value, assuming it is plain stuff: */
     240                    if (*pszTimeZone == '\"' || *pszTimeZone == '\'')
     241                    {
     242                        pszTimeZone++;
     243                        size_t const cchTimeZone = strlen(pszTimeZone);
     244                        if (cchTimeZone && (pszTimeZone[cchTimeZone - 1] == '"' || pszTimeZone[cchTimeZone - 1] == '\''))
     245                            pszTimeZone[cchTimeZone - 1] = '\0';
     246                    }
     247
    235248                    rc = rtIsValidTimeZoneFile(pszTimeZone);
    236249                    if (RT_SUCCESS(rc))
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