VirtualBox

Changeset 59830 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Feb 26, 2016 10:08:15 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
105723
Message:

DnD: HostServices/Service.h: Error checking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/HostServices/Service.h

    r58329 r59830  
    44
    55/*
    6  * Copyright (C) 2011-2015 Oracle Corporation
     6 * Copyright (C) 2011-2016 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6464        if (m_uMsg != uMsg)
    6565        {
    66             LogFlowFunc(("Message type does not match (%u (buffer), %u (guest))\n",
    67                          m_uMsg, uMsg));
     66            LogFlowFunc(("Message type does not match (%RU32 (buffer), %RU32 (guest))\n", m_uMsg, uMsg));
    6867            return VERR_INVALID_PARAMETER;
    6968        }
    70         if (m_cParms != cParms)
     69        if (m_cParms > cParms)
    7170        {
    72             LogFlowFunc(("Parameter count does not match (%u (buffer), %u (guest))\n",
    73                          m_cParms, cParms));
     71            LogFlowFunc(("Parameter count does not match (%RU32 (buffer), %RU32 (guest))\n", m_cParms, cParms));
    7472            return VERR_INVALID_PARAMETER;
    7573        }
    7674
    77         int rc = copyParmsInternal(cParms, m_paParms, &aParms[0], false /* fCreatePtrs */);
    78 
    79 //        if (RT_FAILURE(rc))
    80 //            cleanup(aParms);
    81         return rc;
     75        return copyParmsInternal(&aParms[0], cParms, m_paParms, m_cParms, false /* fDeepCopy */);
    8276    }
    8377
     
    117111    }
    118112
    119     static int copyParms(uint32_t cParms, PVBOXHGCMSVCPARM paParmsSrc, PVBOXHGCMSVCPARM paParmsDst)
    120     {
    121         return copyParmsInternal(cParms, paParmsSrc, paParmsDst, false /* fCreatePtrs */);
     113    static int copyParms(PVBOXHGCMSVCPARM paParmsDst, uint32_t cParmsDst, PVBOXHGCMSVCPARM paParmsSrc, uint32_t cParmsSrc)
     114    {
     115        return copyParmsInternal(paParmsDst, cParmsDst, paParmsSrc, cParmsSrc, false /* fDeepCopy */);
    122116    }
    123117
    124118private:
    125119
    126     uint32_t m_uMsg;
    127     uint32_t m_cParms;
     120    /** Stored message type. */
     121    uint32_t         m_uMsg;
     122    /** Number of stored HGCM parameters. */
     123    uint32_t         m_cParms;
     124    /** Stored HGCM parameters. */
    128125    PVBOXHGCMSVCPARM m_paParms;
    129126
     
    146143        }
    147144
    148         int rc = copyParmsInternal(cParms, &aParms[0], m_paParms, true /* fCreatePtrs */);
    149 
     145        int rc = copyParmsInternal(m_paParms, m_cParms, &aParms[0], cParms, true /* fDeepCopy */);
    150146        if (RT_FAILURE(rc))
    151147            cleanup();
     
    154150    }
    155151
    156     static int copyParmsInternal(uint32_t cParms, PVBOXHGCMSVCPARM paParmsSrc, PVBOXHGCMSVCPARM paParmsDst, bool fCreatePtrs)
    157     {
     152    static int copyParmsInternal(PVBOXHGCMSVCPARM paParmsDst, uint32_t cParmsDst,
     153                                 PVBOXHGCMSVCPARM paParmsSrc, uint32_t cParmsSrc,
     154                                 bool fDeepCopy)
     155    {
     156        AssertPtrReturn(paParmsSrc, VERR_INVALID_POINTER);
     157        AssertPtrReturn(paParmsDst, VERR_INVALID_POINTER);
     158
     159        if (cParmsSrc > cParmsDst)
     160            return VERR_BUFFER_OVERFLOW;
     161
    158162        int rc = VINF_SUCCESS;
    159         for (uint32_t i = 0; i < cParms; ++i)
     163        for (uint32_t i = 0; i < cParmsSrc; i++)
    160164        {
    161165            paParmsDst[i].type = paParmsSrc[i].type;
     
    174178                case VBOX_HGCM_SVC_PARM_PTR:
    175179                {
    176                     /* Do we have to recreate the memory? */
    177                     if (fCreatePtrs)
     180                    /* Do we have to perform a deep copy? */
     181                    if (fDeepCopy)
    178182                    {
    179183                        /* Yes, do so. */
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