From 65172beffe8d9c4aa4b72782a9b76a4972be3c69 Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Wed, 11 Jun 2014 17:21:51 +0200 Subject: [PATCH] Check bus:address and vid:pid validity. --- serialport.c | 4 ++++ 1 file changed, 4 insertions(+) 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;