nolo: Check for return buffer size
This commit is contained in:
1 parent
bc9f42f559
commit
52efd5a404
1 file changed
+6
@@ -124,6 +124,9 @@ static int nolo_identify_string(struct usb_device_info * dev, const char * str,
|
||||
if ( ret < 0 )
|
||||
NOLO_ERROR_RETURN("NOLO_IDENTIFY failed", -1);
|
||||
|
||||
if ( (size_t)ret > sizeof(buf) )
|
||||
ret = sizeof(buf);
|
||||
|
||||
ptr = memmem(buf, ret, str, strlen(str));
|
||||
if ( ! ptr )
|
||||
ERROR_RETURN("Substring was not found", -1);
|
||||
@@ -167,6 +170,9 @@ static int nolo_get_string(struct usb_device_info * dev, char * str, char * out,
|
||||
if ( ( ret = usb_control_msg(dev->udev, NOLO_QUERY, NOLO_GET_STRING, 0, 0, out, size-1, 2000) ) < 0 )
|
||||
return -1;
|
||||
|
||||
if ( (size_t)ret > size-1 )
|
||||
ret = size-1;
|
||||
|
||||
out[size-1] = 0;
|
||||
out[ret] = 0;
|
||||
return strlen(out);
|
||||
|
||||
Reference in new issue
Block a user