VirtualBox

Ignore:
Timestamp:
Feb 19, 2024 12:45:14 PM (14 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
161764
Message:

Storage/{VISO.cpp,ISCSI.cpp}: Verify that there is a config interface before using it, bugref:3409

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/ISCSI.cpp

    r99739 r103435  
    54015401    char *pszLUN     = NULL;
    54025402    char *pszAddress = NULL;
    5403     int rc = VDCFGQueryStringAlloc(VDIfConfigGet(pConfig), "TargetName", &pszTarget);
    5404     if (RT_SUCCESS(rc))
    5405     {
    5406         rc = VDCFGQueryStringAlloc(VDIfConfigGet(pConfig), "LUN", &pszLUN);
     5403
     5404    int rc;
     5405    PVDINTERFACECONFIG pIfCfg = VDIfConfigGet(pConfig);
     5406    if (pIfCfg)
     5407    {
     5408        rc = VDCFGQueryStringAlloc(pIfCfg, "TargetName", &pszTarget);
    54075409        if (RT_SUCCESS(rc))
    54085410        {
    5409             rc = VDCFGQueryStringAlloc(VDIfConfigGet(pConfig), "TargetAddress", &pszAddress);
     5411            rc = VDCFGQueryStringAlloc(pIfCfg, "LUN", &pszLUN);
    54105412            if (RT_SUCCESS(rc))
    54115413            {
    5412                 if (RTStrAPrintf(pszLocation, "iscsi://%s/%s/%s",
    5413                                  pszAddress, pszTarget, pszLUN) < 0)
    5414                     rc = VERR_NO_MEMORY;
     5414                rc = VDCFGQueryStringAlloc(pIfCfg, "TargetAddress", &pszAddress);
     5415                if (RT_SUCCESS(rc))
     5416                {
     5417                    if (RTStrAPrintf(pszLocation, "iscsi://%s/%s/%s",
     5418                                     pszAddress, pszTarget, pszLUN) < 0)
     5419                        rc = VERR_NO_MEMORY;
     5420
     5421                    RTMemFree(pszAddress);
     5422                }
     5423                RTMemFree(pszLUN);
    54155424            }
    5416         }
    5417     }
    5418     RTMemFree(pszTarget);
    5419     RTMemFree(pszLUN);
    5420     RTMemFree(pszAddress);
     5425            RTMemFree(pszTarget);
     5426        }
     5427    }
     5428    else
     5429        rc = VERR_INVALID_PARAMETER;
     5430
    54215431    return rc;
    54225432}
     
    54285438    char *pszLUN     = NULL;
    54295439    char *pszAddress = NULL;
    5430     int rc = VDCFGQueryStringAlloc(VDIfConfigGet(pConfig), "TargetName", &pszTarget);
    5431     if (RT_SUCCESS(rc))
    5432     {
    5433         rc = VDCFGQueryStringAlloc(VDIfConfigGet(pConfig), "LUN", &pszLUN);
     5440
     5441    int rc;
     5442    PVDINTERFACECONFIG pIfCfg = VDIfConfigGet(pConfig);
     5443    if (pIfCfg)
     5444    {
     5445        rc = VDCFGQueryStringAlloc(pIfCfg, "TargetName", &pszTarget);
    54345446        if (RT_SUCCESS(rc))
    54355447        {
    5436             rc = VDCFGQueryStringAlloc(VDIfConfigGet(pConfig), "TargetAddress", &pszAddress);
     5448            rc = VDCFGQueryStringAlloc(pIfCfg, "LUN", &pszLUN);
    54375449            if (RT_SUCCESS(rc))
    54385450            {
    5439                 /** @todo think about a nicer looking location scheme for iSCSI */
    5440                 if (RTStrAPrintf(pszName, "%s/%s/%s",
    5441                                  pszAddress, pszTarget, pszLUN) < 0)
    5442                     rc = VERR_NO_MEMORY;
     5451                rc = VDCFGQueryStringAlloc(pIfCfg, "TargetAddress", &pszAddress);
     5452                if (RT_SUCCESS(rc))
     5453                {
     5454                    /** @todo think about a nicer looking location scheme for iSCSI */
     5455                    if (RTStrAPrintf(pszName, "%s/%s/%s",
     5456                                     pszAddress, pszTarget, pszLUN) < 0)
     5457                        rc = VERR_NO_MEMORY;
     5458
     5459                    RTMemFree(pszAddress);
     5460                }
     5461                RTMemFree(pszLUN);
    54435462            }
    5444         }
    5445     }
    5446     RTMemFree(pszTarget);
    5447     RTMemFree(pszLUN);
    5448     RTMemFree(pszAddress);
     5463            RTMemFree(pszTarget);
     5464        }
     5465    }
     5466    else
     5467        rc = VERR_INVALID_PARAMETER;
    54495468
    54505469    return rc;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette