diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2009-04-27 13:22:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-05-08 22:34:56 -0400 |
commit | 0f43158caddcbb110916212ebe4e39993ae70864 (patch) | |
tree | 8abb9161fedf231180ffa2828010670d51a25357 /drivers/usb | |
parent | 72a772a9a3da47e1cdbe01c4aa1105aa8badfff2 (diff) |
USB: Gadget: fix UTF conversion in the usbstring library
This patch (as1234) fixes a bug in the UTF8 -> UTF-16 conversion
routine in the gadget/usbstring library. In a UTF-8 multi-byte
sequence, all bytes after the first should have their high-order
two bits set to 10, not 11.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/usbstring.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 4154be375c7a..58c4d37d312a 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c | |||
@@ -38,7 +38,7 @@ static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len) | |||
38 | uchar = (c & 0x1f) << 6; | 38 | uchar = (c & 0x1f) << 6; |
39 | 39 | ||
40 | c = (u8) *s++; | 40 | c = (u8) *s++; |
41 | if ((c & 0xc0) != 0xc0) | 41 | if ((c & 0xc0) != 0x80) |
42 | goto fail; | 42 | goto fail; |
43 | c &= 0x3f; | 43 | c &= 0x3f; |
44 | uchar |= c; | 44 | uchar |= c; |
@@ -49,13 +49,13 @@ static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len) | |||
49 | uchar = (c & 0x0f) << 12; | 49 | uchar = (c & 0x0f) << 12; |
50 | 50 | ||
51 | c = (u8) *s++; | 51 | c = (u8) *s++; |
52 | if ((c & 0xc0) != 0xc0) | 52 | if ((c & 0xc0) != 0x80) |
53 | goto fail; | 53 | goto fail; |
54 | c &= 0x3f; | 54 | c &= 0x3f; |
55 | uchar |= c << 6; | 55 | uchar |= c << 6; |
56 | 56 | ||
57 | c = (u8) *s++; | 57 | c = (u8) *s++; |
58 | if ((c & 0xc0) != 0xc0) | 58 | if ((c & 0xc0) != 0x80) |
59 | goto fail; | 59 | goto fail; |
60 | c &= 0x3f; | 60 | c &= 0x3f; |
61 | uchar |= c; | 61 | uchar |= c; |