FU Logo
  • Startseite
  • Kontakt
  • Impressum
  • Home
  • Listenauswahl
  • Anleitungen

[linux-minidisc] Fixing a bug in libnetmd / netmd_open

<-- thread -->
<-- date -->
  • From: Thomas Arp <manner.moe@gmx.de>
  • To: "linux-minidisc@lists.fu-berlin.de" <linux-minidisc@lists.fu-berlin.de>
  • Date: Fri, 26 Apr 2013 20:15:02 +0200
  • Subject: [linux-minidisc] Fixing a bug in libnetmd / netmd_open

Hi,
here is a small patch fixing a bug in libnetmd.
libusb_open() function has to be checked for errors before trying to call libusb_claim_interface(). Else if libusb_open() fails libusb_claim_interface() will be called with a NULL pointer, so it will crash with a segmentation fault.

Maybe we should check the error code to give more detailed information why libusb_open() failed.
This patch is just to prevent any crashes yet.

Thomas
>From 1daad5af51e3886a3d4cdfc3ed76ef692a91205a Mon Sep 17 00:00:00 2001
From: Thomas Arp <manner.moe@gmx.de>
Date: Fri, 26 Apr 2013 19:55:28 +0200
Subject: [PATCH] Check for error code from libusb_open in netmd_open function

---
 libnetmd/netmd_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libnetmd/netmd_dev.c b/libnetmd/netmd_dev.c
index 263e446..0fac0ce 100644
--- a/libnetmd/netmd_dev.c
+++ b/libnetmd/netmd_dev.c
@@ -116,8 +116,8 @@ netmd_error netmd_open(netmd_device *dev, netmd_dev_handle **dev_handle)
     int result;
     libusb_device_handle *dh = NULL;
 
-    libusb_open(dev->usb_dev, &dh);
-    result = libusb_claim_interface(dh, 0);
+    if((result = libusb_open(dev->usb_dev, &dh)) == 0)
+        result = libusb_claim_interface(dh, 0);
 
     if (result == 0) {
         *dev_handle = (netmd_dev_handle*)dh;
-- 
1.8.0.msysgit.0

<-- thread -->
<-- date -->
  • linux-minidisc - April 2013 - Archives indexes sorted by:
    [ thread ] [ subject ] [ author ] [ date ]
  • Complete archive of the linux-minidisc mailing list
  • More info on this list...

Hilfe

  • FAQ
  • Dienstbeschreibung
  • ZEDAT Beratung
  • postmaster@lists.fu-berlin.de

Service-Navigation

  • Startseite
  • Listenauswahl

Einrichtung Mailingliste

  • ZEDAT-Portal
  • Mailinglisten Portal