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

Changeset 12e689f in mainline


Ignore:
Timestamp:
2012-02-24T05:37:19Z (8 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
master
Children:
48f0f73a
Parents:
7f7e6f5
Message:

libusbdev: Do not modify retrieved descriptors, compute required value explicitly.

There might be more such values and we won't convert all.

File:
1 edited

Legend:

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

    r7f7e6f5 r12e689f  
    435435        /* Everything is okay, copy the descriptor. */
    436436        memcpy(descriptor, &descriptor_tmp, sizeof(descriptor_tmp));
    437         descriptor->total_length = uint16_usb2host(descriptor_tmp.total_length);
    438437        return EOK;
    439438}
     
    495494                return ENOENT;
    496495        }
    497         if (bare_config.total_length < sizeof(bare_config)) {
     496
     497        const size_t total_length = uint16_usb2host(bare_config.total_length);
     498        if (total_length < sizeof(bare_config)) {
    498499                return ELIMIT;
    499500        }
    500501
    501         void *buffer = malloc(bare_config.total_length);
     502        void *buffer = malloc(total_length);
    502503        if (buffer == NULL) {
    503504                return ENOMEM;
     
    506507        size_t transferred = 0;
    507508        rc = usb_request_get_full_configuration_descriptor(pipe, index,
    508             buffer, bare_config.total_length, &transferred);
     509            buffer, total_length, &transferred);
    509510        if (rc != EOK) {
    510511                free(buffer);
     
    512513        }
    513514
    514         if (transferred != bare_config.total_length) {
     515        if (transferred != total_length) {
    515516                free(buffer);
    516517                return ELIMIT;
     
    522523
    523524        if (descriptor_size != NULL) {
    524                 *descriptor_size = bare_config.total_length;
     525                *descriptor_size = total_length;
    525526        }
    526527
Note: See TracChangeset for help on using the changeset viewer.