openenclave / oeedger8r-cpp

An implementation of oeedger8r in C++
MIT License
8 stars 13 forks source link

Add OE_ADD_ARG_SIZE macro #70

Closed mingweishih closed 3 years ago

mingweishih commented 3 years ago

Address comments from https://github.com/openenclave/openenclave/pull/3831

Signed-off-by: Ming-Wei Shih mishih@microsoft.com

mingweishih commented 3 years ago

@CodeMonkeyLeet Can you take a look? We need to retain OE_COMPUTE_ARG_SIZE. If we use OE_ADD_ARG_SIZE to calculate _size (say argcount=1, argsize=4), OE_ADD will apply the alignment (16) to the result, making the _size become 16 instead 4. This will cause memory overwritten in memcpy.

#define OE_READ_OUT_PARAM(argname, argcount, argsize)                          \
    if (argname)                                                               \
    {                                                                          \
        size_t _size = 0;                                                      \
        OE_COMPUTE_ARG_SIZE(_size, argcount, argsize);                         \
        memcpy((void*)argname, _output_buffer + _output_buffer_offset, _size); \
        OE_ADD_SIZE(_output_buffer_offset, _size);                             \
    }
oe-ci-robot commented 3 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CodeMonkeyLeet, mingweishih

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/openenclave/oeedger8r-cpp/blob/master/OWNERS)~~ [mingweishih] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment