From: Aurelien Jacobs Date: Wed, 11 Jun 2014 15:21:51 +0000 (+0200) Subject: Check bus:address and vid:pid validity. X-Git-Tag: libserialport-0.1.1~126 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=65172beffe8d9c4aa4b72782a9b76a4972be3c69;p=libserialport.git Check bus:address and vid:pid validity. --- diff --git a/serialport.c b/serialport.c index 0091d9a..558322e 100644 --- a/serialport.c +++ b/serialport.c @@ -148,6 +148,8 @@ enum sp_return sp_get_port_usb_bus_address(const struct sp_port *port, RETURN_ERROR(SP_ERR_ARG, "Null port"); if (port->transport != SP_TRANSPORT_USB) RETURN_ERROR(SP_ERR_ARG, "Port does not use USB transport"); + if (port->usb_bus < 0 || port->usb_address < 0) + RETURN_ERROR(SP_ERR_SUPP, "Bus and address values are not available"); if (usb_bus) *usb_bus = port->usb_bus; if (usb_address) *usb_address = port->usb_address; @@ -164,6 +166,8 @@ enum sp_return sp_get_port_usb_vid_pid(const struct sp_port *port, RETURN_ERROR(SP_ERR_ARG, "Null port"); if (port->transport != SP_TRANSPORT_USB) RETURN_ERROR(SP_ERR_ARG, "Port does not use USB transport"); + if (port->usb_vid < 0 || port->usb_pid < 0) + RETURN_ERROR(SP_ERR_SUPP, "VID:PID values are not available"); if (usb_vid) *usb_vid = port->usb_vid; if (usb_pid) *usb_pid = port->usb_pid;