VirtualBox

Changeset 26959 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 2, 2010 5:08:52 PM (15 years ago)
Author:
vboxsync
Message:

Storage/iSCSI: fix crash when the iSCSI connection could not be established, and another crash caused by using the wrong buffer length in memcpy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/ISCSIHDDCore.cpp

    r26917 r26959  
    330330    /** Size of volume in sectors. */
    331331    uint64_t            cVolume;
    332     /** Total volume size in bytes. Easier that multiplying the above values all the time. */
     332    /** Total volume size in bytes. Easier than multiplying the above values all the time. */
    333333    uint64_t            cbSize;
    334334
     
    882882 *
    883883 * @returns VBox status.
    884  * @param   pImage  The iSCSI connection state to be used.
     884 * @param   pImage      The iSCSI connection state to be used.
    885885 */
    886886static int iscsiAttach(PISCSIIMAGE pImage)
     
    939939restart:
    940940    if (pImage->Socket == NIL_RTSOCKET)
     941    {
    941942        rc = iscsiTransportOpen(pImage);
     943        if (RT_FAILURE(rc))
     944        goto out;
     945    }
    942946
    943947    pImage->state = ISCSISTATE_IN_LOGIN;
     
    13171321 *
    13181322 * @returns VBox status.
    1319  * @param   pImage  The iSCSI connection state to be used.
     1323 * @param   pImage      The iSCSI connection state to be used.
    13201324 */
    13211325static int iscsiDetach(PISCSIIMAGE pImage)
     
    14051409 *
    14061410 * @returns VBOX status.
    1407  * @param   pImage  The iSCSI connection state to be used.
    1408  * @param   pRequest        Command descriptor. Contains all information about
    1409  *                          the command, its transfer directions and pointers
    1410  *                          to the buffer(s) used for transferring data and
    1411  *                          status information.
     1411 * @param   pImage      The iSCSI connection state to be used.
     1412 * @param   pRequest    Command descriptor. Contains all information about
     1413 *                      the command, its transfer directions and pointers
     1414 *                      to the buffer(s) used for transferring data and
     1415 *                      status information.
    14121416 */
    14131417static int iscsiCommand(PISCSIIMAGE pImage, PSCSIREQ pRequest)
     
    16271631 *
    16281632 * @returns Initiator Task Tag.
    1629  * @param   pImage  The iSCSI connection state to be used.
     1633 * @param   pImage      The iSCSI connection state to be used.
    16301634 */
    16311635static uint32_t iscsiNewITT(PISCSIIMAGE pImage)
     
    16451649 *
    16461650 * @returns VBOX status
    1647  * @param   pImage  The iSCSI connection state to be used.
    1648  * @param   paReq      Pointer to array of iSCSI request sections.
    1649  * @param   cnReq      Number of valid iSCSI request sections in the array.
     1651 * @param   pImage      The iSCSI connection state to be used.
     1652 * @param   paReq       Pointer to array of iSCSI request sections.
     1653 * @param   cnReq       Number of valid iSCSI request sections in the array.
    16501654 */
    16511655static int iscsiSendPDU(PISCSIIMAGE pImage, PISCSIREQ paReq, uint32_t cnReq)
    16521656{
    16531657    int rc = VINF_SUCCESS;
    1654     uint32_t i;
    16551658    /** @todo return VERR_VD_ISCSI_INVALID_STATE in the appropriate situations,
    16561659     * needs cleaning up of timeout/disconnect handling a bit, as otherwise
     
    16601663    Assert(paReq[0].cbSeg >= ISCSI_BHS_SIZE);
    16611664
    1662     for (i = 0; i < pImage->cISCSIRetries; i++)
     1665    for (uint32_t i = 0; i < pImage->cISCSIRetries; i++)
    16631666    {
    16641667        rc = iscsiTransportWrite(pImage, paReq, cnReq);
     
    16911694 *
    16921695 * @returns VBOX status
    1693  * @param   pImage  The iSCSI connection state to be used.
    1694  * @param   paRes      Pointer to array of iSCSI response sections.
    1695  * @param   cnRes      Number of valid iSCSI response sections in the array.
     1696 * @param   pImage      The iSCSI connection state to be used.
     1697 * @param   paRes       Pointer to array of iSCSI response sections.
     1698 * @param   cnRes       Number of valid iSCSI response sections in the array.
    16961699 */
    16971700static int iscsiRecvPDU(PISCSIIMAGE pImage, uint32_t itt, PISCSIRES paRes, uint32_t cnRes)
    16981701{
    16991702    int rc = VINF_SUCCESS;
    1700     uint32_t i;
    17011703    ISCSIRES aResBuf;
    17021704
    1703     for (i = 0; i < pImage->cISCSIRetries; i++)
     1705    for (uint32_t i = 0; i < pImage->cISCSIRetries; i++)
    17041706    {
    17051707        aResBuf.pvSeg = pImage->pvRecvPDUBuf;
     
    18011803                    if (cbSeg > paRes[j].cbSeg)
    18021804                    {
    1803                         memcpy(paRes[j].pvSeg, pSrc, paRes[i].cbSeg);
     1805                        memcpy(paRes[j].pvSeg, pSrc, paRes[j].cbSeg);
    18041806                        pSrc += paRes[j].cbSeg;
    18051807                        cbSeg -= paRes[j].cbSeg;
     
    18591861 *
    18601862 * @returns VBOX status
    1861  * @param   paRes      Pointer to array of iSCSI response sections.
    1862  * @param   cnRes      Number of valid iSCSI response sections in the array.
     1863 * @param   paRes       Pointer to array of iSCSI response sections.
     1864 * @param   cnRes       Number of valid iSCSI response sections in the array.
    18631865 */
    18641866static int drvISCSIValidatePDU(PISCSIRES paRes, uint32_t cnRes)
     
    20162018 *
    20172019 * @returns VBOX status.
    2018  * @param   pbBuf      Buffer containing key=value pairs.
    2019  * @param   cbBuf      Length of buffer with key=value pairs.
    2020  * @param   pszKey     Pointer to key for which to retrieve the value.
    2021  * @param   ppszValue  Pointer to value string pointer.
     2020 * @param   pbBuf       Buffer containing key=value pairs.
     2021 * @param   cbBuf       Length of buffer with key=value pairs.
     2022 * @param   pszKey      Pointer to key for which to retrieve the value.
     2023 * @param   ppszValue   Pointer to value string pointer.
    20222024 */
    20232025static int iscsiTextGetKeyValue(const uint8_t *pbBuf, size_t cbBuf, const char *pcszKey, const char **ppcszValue)
     
    21482150 *
    21492151 * @returns VBOX status.
    2150  * @param   pImage     Current iSCSI initiator state.
    2151  * @param   pbBuf      Buffer containing key=value pairs.
    2152  * @param   cbBuf      Length of buffer with key=value pairs.
     2152 * @param   pImage      Current iSCSI initiator state.
     2153 * @param   pbBuf       Buffer containing key=value pairs.
     2154 * @param   cbBuf       Length of buffer with key=value pairs.
    21532155 */
    21542156static int iscsiUpdateParameters(PISCSIIMAGE pImage, const uint8_t *pbBuf, size_t cbBuf)
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