diff options
| author | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2018-05-17 15:19:29 +0000 |
|---|---|---|
| committer | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2018-05-17 15:19:29 +0000 |
| commit | 2d1a76975e07946fd82cdd9c94857add59047678 (patch) | |
| tree | e2a0b0074320dcf422bdebf265bb95d14c9ef039 /sys/dev/usb/template | |
| parent | 6f78fad3b102965147e6e15a8422bd157b699993 (diff) | |
Notes
Diffstat (limited to 'sys/dev/usb/template')
| -rw-r--r-- | sys/dev/usb/template/usb_template.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/dev/usb/template/usb_template.c b/sys/dev/usb/template/usb_template.c index 077974523302..42a012125ff1 100644 --- a/sys/dev/usb/template/usb_template.c +++ b/sys/dev/usb/template/usb_template.c @@ -127,7 +127,12 @@ usb_decode_str_desc(struct usb_string_descriptor *sd, char *buf, size_t buflen) { size_t i; - for (i = 0; i < buflen - 1 && i < sd->bLength / 2; i++) + if (sd->bLength < 2) { + buf[0] = '\0'; + return; + } + + for (i = 0; i < buflen - 1 && i < (sd->bLength / 2) - 1; i++) buf[i] = UGETW(sd->bString[i]); buf[i] = '\0'; |
