This is an automated email from Gerrit.

Jörg Wunsch ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/2044

-- gerrit

commit 22a1f7e19026e7dc36b6155c7864b7221e94fecc
Author: Jörg Wunsch <[email protected]>
Date:   Fri Mar 14 10:50:36 2014 +0100

    topic: Prevent segfault when the USB product string cannot be retrieved
    
    In the CMSIS-DAP driver, if nothing has been specified by the user, an
    attempt is made to find the first device with the (mandatory)
    substring "CMSIS-DAP" in any USB device's product string.  However,
    while (usually) all devices can be traversed, devices the user does
    not have permission for cannot be read the product string from,
    resulting in a NULL pointer.  Trying to find the substring "CMSIS-DAP"
    causes a segementation fault then.
    
    This has also been filed as Trac bug #67:
    
    https://sourceforge.net/apps/trac/openocd/ticket/67
    
    Change-Id: Idfc9f072e34152e9af99fe1c8ec88c99dea4624c
    Signed-off-by: Jörg Wunsch <[email protected]>

diff --git a/src/jtag/drivers/cmsis_dap_usb.c b/src/jtag/drivers/cmsis_dap_usb.c
index f4d08ca..504b3d0 100644
--- a/src/jtag/drivers/cmsis_dap_usb.c
+++ b/src/jtag/drivers/cmsis_dap_usb.c
@@ -173,7 +173,8 @@ static int cmsis_dap_usb_open(void)
        devs = hid_enumerate(0x0, 0x0);
        cur_dev = devs;
        while (NULL != cur_dev) {
-               if ((0 == cmsis_dap_vid[0]) && wcsstr(cur_dev->product_string, 
L"CMSIS-DAP")) {
+               if ((0 == cmsis_dap_vid[0]) && (NULL != cur_dev->product_string)
+                   && wcsstr(cur_dev->product_string, L"CMSIS-DAP")) {
                        /*
                        if the user hasn't specified VID:PID *and*
                        product string contains "CMSIS-DAP", pick it

-- 

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to