summaryrefslogtreecommitdiff
path: root/winpr-crt-Fix-wcs-cmp-and-wcs-len-checks.patch
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2024-08-01 15:09:08 +0000
committerCoprDistGit <infra@openeuler.org>2024-08-01 15:09:08 +0000
commit0b1f438f59e230389519ba100f28b896df14e08b (patch)
tree22651934332deb73602326a03ddb24bffa8d18fc /winpr-crt-Fix-wcs-cmp-and-wcs-len-checks.patch
parent5c96aee787beb29707ea3203fcef7f3b3b637153 (diff)
automatic import of freerdpopeneuler24.03_LTSopeneuler23.09
Diffstat (limited to 'winpr-crt-Fix-wcs-cmp-and-wcs-len-checks.patch')
-rw-r--r--winpr-crt-Fix-wcs-cmp-and-wcs-len-checks.patch90
1 files changed, 90 insertions, 0 deletions
diff --git a/winpr-crt-Fix-wcs-cmp-and-wcs-len-checks.patch b/winpr-crt-Fix-wcs-cmp-and-wcs-len-checks.patch
new file mode 100644
index 0000000..1ae664d
--- /dev/null
+++ b/winpr-crt-Fix-wcs-cmp-and-wcs-len-checks.patch
@@ -0,0 +1,90 @@
+From fb9d753af70b449dd7a17898d46fd57822a08dc1 Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Thu, 10 Nov 2022 14:21:22 +0100
+Subject: [PATCH] [winpr, crt] Fix wcs*cmp and wcs*len checks
+
+(cherry picked from commit b60fac1a0470fe83e8d0b448f0fd7e9e6d6a0f96)
+---
+ winpr/libwinpr/crt/string.c | 30 +++++++++++++++++++-----------
+ 1 file changed, 19 insertions(+), 11 deletions(-)
+
+diff --git a/winpr/libwinpr/crt/string.c b/winpr/libwinpr/crt/string.c
+index c25ffa279..5dcf4b3f1 100644
+--- a/winpr/libwinpr/crt/string.c
++++ b/winpr/libwinpr/crt/string.c
+@@ -26,6 +26,7 @@
+ #include <wctype.h>
+
+ #include <winpr/crt.h>
++#include <assert.h>
+ #include <winpr/endian.h>
+
+ /* String Manipulation (CRT): http://msdn.microsoft.com/en-us/library/f0151s4x.aspx */
+@@ -80,21 +81,28 @@ int _strnicmp(const char* string1, const char* string2, size_t count)
+
+ int _wcscmp(const WCHAR* string1, const WCHAR* string2)
+ {
+- WCHAR value1, value2;
++ assert(string1);
++ assert(string2);
+
+- while (*string1 && (*string1 == *string2))
++ while (TRUE)
+ {
+- string1++;
+- string2++;
++ const WCHAR w1 = *string1++;
++ const WCHAR w2 = *string2++;
++
++ if (w1 != w2)
++ return (int)w1 - w2;
++ else if ((w1 == '\0') || (w2 == '\0'))
++ return (int)w1 - w2;
+ }
+
+- Data_Read_UINT16(string1, value1);
+- Data_Read_UINT16(string2, value2);
+- return (int)value1 - value2;
++ return 0;
+ }
+
+ int _wcsncmp(const WCHAR* string1, const WCHAR* string2, size_t count)
+ {
++ assert(string1);
++ assert(string2);
++
+ for (size_t x = 0; x < count; x++)
+ {
+ const WCHAR a = string1[x];
+@@ -102,6 +110,8 @@ int _wcsncmp(const WCHAR* string1, const WCHAR* string2, size_t count)
+
+ if (a != b)
+ return (int)a - b;
++ else if ((a == '\0') || (b == '\0'))
++ return (int)a - b;
+ }
+ return 0;
+ }
+@@ -112,8 +122,7 @@ size_t _wcslen(const WCHAR* str)
+ {
+ const WCHAR* p = (const WCHAR*)str;
+
+- if (!p)
+- return 0;
++ assert(p);
+
+ while (*p)
+ p++;
+@@ -127,8 +136,7 @@ size_t _wcsnlen(const WCHAR* str, size_t max)
+ {
+ size_t x;
+
+- if (!str)
+- return 0;
++ assert(str);
+
+ for (x = 0; x < max; x++)
+ {
+--
+2.37.1
+