1From 4e04afc2df9bbc26e5ab524b53a6f4f1e61d7c9e Mon Sep 17 00:00:00 2001 2From: Javier Martinez Canillas <javierm@redhat.com> 3Date: Tue, 5 Mar 2019 17:23:32 +0100 4Subject: [PATCH] ucs2.h: fix logic that checks for UCS-2 string termination 5 6Currently the loop to count the lenght of the UCS-2 string ends if either 7of the two bytes are 0, but 0 is a valid value for UCS-2 character codes. 8 9So only break the loop when 0 is the value for both UCS-2 char bytes. 10 11Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> 12Signed-off-by: Peter Korsgaard <peter@korsgaard.com> 13--- 14 src/ucs2.h | 2 +- 15 1 file changed, 1 insertion(+), 1 deletion(-) 16 17diff --git a/src/ucs2.h b/src/ucs2.h 18index e0390c3..fd8b056 100644 19--- a/src/ucs2.h 20+++ b/src/ucs2.h 21@@ -29,7 +29,7 @@ ucs2len(const void *vs, ssize_t limit) 22 const uint8_t *s8 = vs; 23 24 for (i = 0; 25- i < (limit >= 0 ? limit : i+1) && s8[0] != 0 && s8[1] != 0; 26+ i < (limit >= 0 ? limit : i+1) && !(s8[0] == 0 && s8[1] == 0); 27 i++, s8 += 2) 28 ; 29 return i; 30-- 312.20.1 32 33