VirtualBox

Changeset 21848 in vbox


Ignore:
Timestamp:
Jul 28, 2009 2:45:02 PM (15 years ago)
Author:
vboxsync
Message:

zip.cpp: make sure we return VERR_NOT_SUPPORTED for attempts using compression types that aren't enabled in the build.

File:
1 edited

Legend:

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

    r21844 r21848  
    6161#endif
    6262#ifdef RTZIP_USE_LZO
    63 #include <lzo/lzo1x.h>
     63# include <lzo/lzo1x.h>
    6464#endif
    6565
     
    259259
    260260#ifdef RTZIP_USE_STORE
    261 #include <stdio.h>
    262261
    263262/**
     
    417416}
    418417
    419 #endif
     418#endif /* RTZIP_USE_STORE */
    420419
    421420
     
    635634}
    636635
    637 #endif
     636#endif /* RTZIP_USE_ZLIB */
    638637
    639638
     
    858857}
    859858
    860 #endif
     859#endif /* RTZIP_USE_BZLIB */
    861860
    862861
     
    13361335     * Validate input.
    13371336     */
    1338     if (    enmType < RTZIPTYPE_AUTO
    1339         ||  enmType > RTZIPTYPE_LZF)
    1340     {
    1341         AssertMsgFailed(("Invalid enmType=%d\n", enmType));
    1342         return VERR_INVALID_PARAMETER;
    1343     }
    1344     if (    enmLevel < RTZIPLEVEL_STORE
    1345         ||  enmLevel > RTZIPLEVEL_MAX)
    1346     {
    1347         AssertMsgFailed(("Invalid enmLevel=%d\n", enmLevel));
    1348         return VERR_INVALID_PARAMETER;
    1349     }
    1350     if (!pfnOut || !ppZip)
    1351     {
    1352         AssertMsgFailed(("Must supply pfnOut and ppZip!\n"));
    1353         return VERR_INVALID_PARAMETER;
    1354     }
     1337    AssertReturn(enmType >= RTZIPTYPE_INVALID && enmType < RTZIPTYPE_END, VERR_INVALID_PARAMETER);
     1338    AssertReturn(enmLevel >= RTZIPLEVEL_STORE && enmLevel <= RTZIPLEVEL_MAX, VERR_INVALID_PARAMETER);
     1339    AssertPtrReturn(pfnOut, VERR_INVALID_POINTER);
     1340    AssertPtrReturn(ppZip, VERR_INVALID_POINTER);
    13551341
    13561342    /*
     
    13921378    pZip->pvUser  = pvUser;
    13931379    pZip->abBuffer[0] = enmType;       /* first byte is the compression type. */
    1394     int rc = VINF_SUCCESS;
     1380    int rc = VERR_NOT_IMPLEMENTED;
    13951381    switch (enmType)
    13961382    {
     1383        case RTZIPTYPE_STORE:
    13971384#ifdef RTZIP_USE_STORE
    1398         case RTZIPTYPE_STORE:
    13991385            rc = rtZipStoreCompInit(pZip, enmLevel);
    1400             break;
    1401 #endif
    1402 
     1386#endif
     1387            break;
     1388
     1389        case RTZIPTYPE_ZLIB:
    14031390#ifdef RTZIP_USE_ZLIB
    1404         case RTZIPTYPE_ZLIB:
    14051391            rc = rtZipZlibCompInit(pZip, enmLevel);
    1406             break;
    1407 #endif
    1408 
     1392#endif
     1393            break;
     1394
     1395        case RTZIPTYPE_BZLIB:
    14091396#ifdef RTZIP_USE_BZLIB
    1410         case RTZIPTYPE_BZLIB:
    14111397            rc = rtZipBZlibCompInit(pZip, enmLevel);
    1412             break;
    1413 #endif
    1414 
     1398#endif
     1399            break;
     1400
     1401        case RTZIPTYPE_LZF:
    14151402#ifdef RTZIP_USE_LZF
    1416         case RTZIPTYPE_LZF:
    14171403            rc = rtZipLZFCompInit(pZip, enmLevel);
    1418             break;
    1419 #endif
     1404#endif
     1405            break;
     1406
     1407        case RTZIPTYPE_LZJB:
     1408        case RTZIPTYPE_LZO:
     1409            break;
    14201410
    14211411        default:
    1422             AssertMsgFailed(("Not implemented!\n"));
    1423             rc = VERR_NOT_IMPLEMENTED;
    1424             break;
     1412            AssertFailedBreak();
    14251413    }
    14261414
     
    15201508     * Validate input.
    15211509     */
    1522     if (!pfnIn || !ppZip)
    1523     {
    1524         AssertMsgFailed(("Must supply pfnIn and ppZip!\n"));
    1525         return VERR_INVALID_PARAMETER;
    1526     }
     1510    AssertPtrReturn(pfnIn, VERR_INVALID_POINTER);
     1511    AssertPtrReturn(ppZip, VERR_INVALID_POINTER);
    15271512
    15281513    /*
     
    15671552     */
    15681553    pZip->enmType = (RTZIPTYPE)u8Type;
     1554    rc = VERR_NOT_SUPPORTED;
    15691555    switch (pZip->enmType)
    15701556    {
     1557        case RTZIPTYPE_STORE:
    15711558#ifdef RTZIP_USE_STORE
    1572         case RTZIPTYPE_STORE:
    15731559            rc = rtZipStoreDecompInit(pZip);
    1574             break;
    1575 #endif
     1560#else
     1561            AssertMsgFailed(("Store is not include in this build!\n"));
     1562#endif
     1563            break;
    15761564
    15771565        case RTZIPTYPE_ZLIB:
     
    15791567            rc = rtZipZlibDecompInit(pZip);
    15801568#else
    1581             AssertMsgFailedReturn(("Zlib is not include in this build!\n"), VERR_NOT_IMPLEMENTED);
     1569            AssertMsgFailed(("Zlib is not include in this build!\n"));
    15821570#endif
    15831571            break;
     
    15871575            rc = rtZipBZlibDecompInit(pZip);
    15881576#else
    1589             AssertMsgFailedReturn(("BZlib is not include in this build!\n"), VERR_NOT_IMPLEMENTED);
     1577            AssertMsgFailed(("BZlib is not include in this build!\n"));
    15901578#endif
    15911579            break;
     
    15951583            rc = rtZipLZFDecompInit(pZip);
    15961584#else
    1597             AssertMsgFailedReturn(("LZF is not include in this build!\n"), VERR_NOT_IMPLEMENTED);
    1598 #endif
    1599             break;
    1600 
    1601         case RTZIPTYPE_INVALID:
    1602             AssertMsgFailed(("Invalid compression type RTZIPTYPE_INVALID!\n"));
    1603             rc = VERR_NOT_IMPLEMENTED;
    1604             break;
    1605 
    1606         case RTZIPTYPE_AUTO:
    1607             AssertMsgFailed(("Invalid compression type RTZIPTYPE_AUTO!\n"));
    1608             rc = VERR_INVALID_MAGIC;
     1585            AssertMsgFailed(("LZF is not include in this build!\n"));
     1586#endif
     1587            break;
     1588
     1589        case RTZIPTYPE_LZJB:
     1590#ifdef RTZIP_USE_LZJB
     1591            AssertMsgFailed(("LZJB streaming support is not implemented yet!\n"));
     1592#else
     1593            AssertMsgFailed(("LZJB is not include in this build!\n"));
     1594#endif
     1595            break;
     1596
     1597        case RTZIPTYPE_LZO:
     1598#ifdef RTZIP_USE_LZJB
     1599            AssertMsgFailed(("LZO streaming support is not implemented yet!\n"));
     1600#else
     1601            AssertMsgFailed(("LZO is not include in this build!\n"));
     1602#endif
    16091603            break;
    16101604
    16111605        default:
    1612             AssertMsgFailed(("Unknown compression type %d\n\n", pZip->enmType));
     1606            AssertMsgFailed(("Invalid compression type %d (%#x)!\n", pZip->enmType, pZip->enmType));
    16131607            rc = VERR_INVALID_MAGIC;
    16141608            break;
     
    16221616    return rc;
    16231617}
     1618
    16241619
    16251620/**
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