~ubuntu-branches/ubuntu/saucy/libusbx/saucy-proposed

« back to all changes in this revision

Viewing changes to libusb/descriptor.c

  • Committer: Package Import Robot
  • Author(s): Aurelien Jarno
  • Date: 2013-05-06 17:31:43 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130506173143-wfbiltvcnn7pvdpa
Tags: 2:1.0.15-1
* New upstream version.
* Fix cross-build (closes: #694912, #705658).
* Add a -dbg package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
229
229
                                        header.bLength);
230
230
                                r = LIBUSB_ERROR_IO;
231
231
                                goto err;
 
232
                        } else if (header.bLength > size) {
 
233
                                usbi_warn(ctx, "invalid descriptor of length %d",
 
234
                                        header.bLength);
 
235
                                /* The remaining bytes are bogus, but at least
 
236
                                 * one interface is OK, so let's continue. */
 
237
                                break;
232
238
                        }
233
239
 
234
240
                        /* If we find another "proper" descriptor then we're done */
371
377
                while (size >= DESC_HEADER_LENGTH) {
372
378
                        usbi_parse_descriptor(buffer, "bb", &header, 0);
373
379
 
 
380
                        /* If we've parsed at least one config descriptor then
 
381
                         * let's return that. */
 
382
                        if (header.bLength > size && i) {
 
383
                                usbi_warn(ctx, "invalid descriptor length of %d",
 
384
                                        header.bLength);
 
385
                                return size;
 
386
                        }
 
387
 
374
388
                        if ((header.bLength > size) ||
375
389
                                        (header.bLength < DESC_HEADER_LENGTH)) {
376
390
                                usbi_err(ctx, "invalid descriptor length of %d",
720
734
                if (di >= (length - 1))
721
735
                        break;
722
736
 
723
 
                if (tbuf[si + 1]) /* high byte */
 
737
                if ((tbuf[si] & 0x80) || (tbuf[si + 1])) /* non-ASCII */
724
738
                        data[di++] = '?';
725
739
                else
726
740
                        data[di++] = tbuf[si];