Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 69b9740 in mainline


Ignore:
Timestamp:
2011-11-28T17:14:48Z (9 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
master
Children:
9dbfd288
Parents:
0255d36
Message:

libusbdev: Add to array end check to alternate interfaces initialization.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/altiface.c

    r0255d36 r69b9740  
    127127        };
    128128
    129         usb_alternate_interface_descriptors_t *cur_alt_iface
     129        usb_alternate_interface_descriptors_t *iterator
    130130            = &alternates->alternatives[0];
     131
     132        const usb_alternate_interface_descriptors_t *end
     133            = &alternates->alternatives[alternates->alternative_count];
    131134
    132135        const void *iface_ptr =
    133136            usb_dp_get_nested_descriptor(&dp_parser, &dp_data, dp_data.data);
    134137
    135         while (iface_ptr != NULL) {
     138        while (iface_ptr != NULL && iterator < end) {
    136139                const usb_standard_interface_descriptor_t *iface = iface_ptr;
    137140
     
    145148                }
    146149
    147                 cur_alt_iface->interface = iface;
    148                 cur_alt_iface->nested_descriptors = iface_ptr + sizeof(*iface);
     150                iterator->interface = iface;
     151                iterator->nested_descriptors = iface_ptr + sizeof(*iface);
    149152
    150153                /* Find next interface to count size of nested descriptors. */
     
    155158                    dp_data.data + dp_data.size : iface_ptr;
    156159
    157                 cur_alt_iface->nested_descriptors_size
    158                     = next - cur_alt_iface->nested_descriptors;
     160                iterator->nested_descriptors_size
     161                    = next - iterator->nested_descriptors;
    159162
    160                 ++cur_alt_iface;
     163                ++iterator;
    161164        }
    162165
Note: See TracChangeset for help on using the changeset viewer.