Deleted Added
sdiff udiff text old ( 198376 ) new ( 199055 )
full compact
1/* $FreeBSD: head/lib/libusb/libusb20_ugen20.c 199055 2009-11-08 20:03:52Z thompsa $ */
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 434 unchanged lines hidden (view full) ---

444 uint8_t **ppbuf, uint16_t *plen, uint8_t cfg_index)
445{
446 struct usb_gen_descriptor gen_desc;
447 struct usb_config_descriptor cdesc;
448 uint8_t *ptr;
449 uint16_t len;
450 int error;
451
452 /* make sure memory is initialised */
453 memset(&cdesc, 0, sizeof(cdesc));
454 memset(&gen_desc, 0, sizeof(gen_desc));
455
456 gen_desc.ugd_data = &cdesc;
457 gen_desc.ugd_maxlen = sizeof(cdesc);
458 gen_desc.ugd_config_index = cfg_index;
459
460 error = ioctl(pdev->file_ctrl, USB_GET_FULL_DESC, &gen_desc);
461 if (error) {
462 return (LIBUSB20_ERROR_OTHER);
463 }
464 len = UGETW(cdesc.wTotalLength);
465 if (len < sizeof(cdesc)) {
466 /* corrupt descriptor */
467 return (LIBUSB20_ERROR_OTHER);
468 }
469 ptr = malloc(len);
470 if (!ptr) {
471 return (LIBUSB20_ERROR_NO_MEM);
472 }
473
474 /* make sure memory is initialised */
475 memset(ptr, 0, len);
476
477 gen_desc.ugd_data = ptr;
478 gen_desc.ugd_maxlen = len;
479
480 error = ioctl(pdev->file_ctrl, USB_GET_FULL_DESC, &gen_desc);
481 if (error) {
482 free(ptr);
483 return (LIBUSB20_ERROR_OTHER);
484 }

--- 511 unchanged lines hidden ---