VirtualBox

Changeset 34952 in vbox


Ignore:
Timestamp:
Dec 10, 2010 2:15:46 PM (14 years ago)
Author:
vboxsync
Message:

tar.cpp: < 8GB, not <=. Added note about using 256-base encoding with the old ustar format. Return MIN/MAX instead of 0 on overflow.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/zip/tar.cpp

    r34951 r34952  
    195195DECLINLINE(void) rtTarSizeToRec(PRTTARRECORD pRecord, uint64_t cbSize)
    196196{
    197     /* Small enough for the standard octal string encoding? */
    198     if (cbSize <= 2 * _4G)
     197    /*
     198     * Small enough for the standard octal string encoding?
     199     *
     200     * Note! We could actually use the terminator character as well if we liked,
     201     *       but let not do that as it's easier to test this way.
     202     */
     203    if (cbSize < _4G * 2U)
    199204        RTStrPrintf(pRecord->h.size, sizeof(pRecord->h.size), "%0.11llo", cbSize);
    200205    else
     
    204209         * We don't deal with negatives here, cause the size have to be greater
    205210         * than zero.
     211         *
     212         * Note! The base-256 extension are never used by gtar or libarchive
     213         *       with the "ustar  \0" format version, only the later
     214         *       "ustar\000" version.  However, this shouldn't cause much
     215         *       trouble as they are not picky about what they read.
    206216         */
    207217        size_t cchField = sizeof(pRecord->h.size) - 1;
     
    210220        do
    211221        {
    212             puchField[cchField--] = cbSize & ((1 << 8) - 1);
    213             cbSize = (cbSize >> 8);
     222            puchField[cchField--] = cbSize & 0xff;
     223            cbSize >>= 8;
    214224        } while (cchField);
    215225    }
     
    239249                            || cbSize < INT64_MIN / 256))
    240250            {
    241                 cbSize = 0;
     251                cbSize = cbSize < 0 ? INT64_MIN : INT64_MAX;
    242252                break;
    243253            }
     
    319329    /** @todo check for field overflows. */
    320330    /* Fill the header record */
    321 //    RT_ZERO(pRecord);
     331//    RT_ZERO(pRecord); - done by the caller.
    322332    RTStrPrintf(pRecord->h.name,  sizeof(pRecord->h.name),  "%s",       pszSrcName);
    323333    RTStrPrintf(pRecord->h.mode,  sizeof(pRecord->h.mode),  "%0.7o",    fmode);
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