Skip to content

Order of operations error and missing exception handling #22

@ChopperCharles

Description

@ChopperCharles

In NDisDriver.c, line 1531 the following code will always evaluate to 0:

tag_us = (qinfo.TagHeader.UserPriority & 0x07 << 13) |
(qinfo.TagHeader.CanonicalFormatId & 0x01 << 12) |
(qinfo.TagHeader.VlanId & 0x0FFF);

This is because the shift operations take precedence over the and operations. To correct this, add parenthesis as such:

tag_us = ((qinfo.TagHeader.UserPriority & 0x07) << 13) |
((qinfo.TagHeader.CanonicalFormatId & 0x01) << 12) |
(qinfo.TagHeader.VlanId & 0x0FFF);

In addition, anywhere there is a ProbeForRead or ProbeForWrite, these should be surrounded by a _try / _except block (and so should any additional access to the buffers). See https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/nf-wdm-probeforread for more information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions