From 96a259de75018d0edf4d2df1a5e575a631b3f870 Mon Sep 17 00:00:00 2001 From: David Brownell <david-b@pacbell.net> Date: Wed, 9 Jul 2003 06:52:04 -0700 Subject: [PATCH] [PATCH] USB: usb_get_string(), don't use bogus ids This fixes a problem that's been around for some time: usbcore will sometimes use un-initialized memory as if it holds a valid language code. --- drivers/usb/core/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index c89dbf4ec122..839cbe6132f6 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -986,7 +986,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) if (err < 0) { err("error getting string descriptor 0 (error=%d)", err); goto errout; - } else if (tbuf[0] < 4) { + } else if (err < 4 || tbuf[0] < 4) { err("string descriptor 0 too short"); err = -EINVAL; goto errout; -- 2.30.9