libusb20_ugen20.c (198376) | libusb20_ugen20.c (199055) |
---|---|
1/* $FreeBSD: head/lib/libusb/libusb20_ugen20.c 198376 2009-10-22 21:01:41Z thompsa $ */ | 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 | 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)); |
|
452 memset(&gen_desc, 0, sizeof(gen_desc)); 453 454 gen_desc.ugd_data = &cdesc; 455 gen_desc.ugd_maxlen = sizeof(cdesc); 456 gen_desc.ugd_config_index = cfg_index; 457 458 error = ioctl(pdev->file_ctrl, USB_GET_FULL_DESC, &gen_desc); 459 if (error) { 460 return (LIBUSB20_ERROR_OTHER); 461 } 462 len = UGETW(cdesc.wTotalLength); 463 if (len < sizeof(cdesc)) { 464 /* corrupt descriptor */ 465 return (LIBUSB20_ERROR_OTHER); 466 } 467 ptr = malloc(len); 468 if (!ptr) { 469 return (LIBUSB20_ERROR_NO_MEM); 470 } | 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 |
|
471 gen_desc.ugd_data = ptr; 472 gen_desc.ugd_maxlen = len; 473 474 error = ioctl(pdev->file_ctrl, USB_GET_FULL_DESC, &gen_desc); 475 if (error) { 476 free(ptr); 477 return (LIBUSB20_ERROR_OTHER); 478 } --- 511 unchanged lines hidden --- | 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 --- |