Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
05c985f5f0
!19 [sync] PR-17: Add sw_64 support
From: @openeuler-sync-bot 
Reviewed-by: @tzing_t 
Signed-off-by: @tzing_t
2025-03-06 06:41:02 +00:00
zhangshaoning
21af75522b Add sw_64 support
(cherry picked from commit 16037f9b1811f9593e17e61015f7bfc33a2bf1d5)
2025-03-05 14:08:21 +08:00
openeuler-ci-bot
25d7a8db88
!12 ujson add support for loongarch64
From: @dpdwaj 
Reviewed-by: @han-guangyu 
Signed-off-by: @han-guangyu
2023-12-04 05:24:04 +00:00
doupengda
3433851815 ujson add support for loongarch64 2023-11-07 20:07:32 +08:00
openeuler-ci-bot
03b75bed13
!10 fix CVE-202-31117
From: @huangduirong 
Reviewed-by: @xiyuanwang 
Signed-off-by: @xiyuanwang
2023-03-01 02:24:55 +00:00
huangduirong
1a2b1ec94f fix CVE-2022-31117 2023-02-28 20:35:08 -05:00
openeuler-ci-bot
fa1bc3da5a
!7 fix CVE-2022-31116
From: @huangduirong 
Reviewed-by: @xiyuanwang 
Signed-off-by: @xiyuanwang
2023-02-27 06:10:33 +00:00
huangduirong
e135aec5ae fix CVE-2022-31116 2023-02-27 00:01:37 -05:00
openeuler-ci-bot
9aaecd48b4
!5 Update package ujson of version 5.1.0
From: @han-guangyu 
Reviewed-by: @huangtianhua 
Signed-off-by: @huangtianhua
2022-05-24 07:08:24 +00:00
han-guangyu
140e098734 Update package ujson of version 5.1.0 2022-05-19 07:34:18 +00:00
6 changed files with 348 additions and 12 deletions

View File

@ -0,0 +1,22 @@
From 662a76a05dfa337e0317022920380596931e64ce Mon Sep 17 00:00:00 2001
From: loongarch <loongarch@localhost.localdomain>
Date: Tue, 7 Nov 2023 20:02:58 +0800
Subject: [PATCH] ujson-5.1.0 add support for loongarch64
diff --git a/deps/double-conversion/double-conversion/utils.h b/deps/double-conversion/double-conversion/utils.h
index 85b1ca4..7830972 100644
--- a/deps/double-conversion/double-conversion/utils.h
+++ b/deps/double-conversion/double-conversion/utils.h
@@ -77,7 +77,7 @@ inline void abort_noreturn() { abort(); }
defined(__SH4__) || defined(__alpha__) || \
defined(_MIPS_ARCH_MIPS32R2) || \
defined(__AARCH64EL__) || defined(__aarch64__) || defined(_M_ARM64) || \
- defined(__riscv)
+ defined(__riscv) || defined(__loongarch64)
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
#elif defined(__mc68000__)
#undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS
--
2.33.0

View File

@ -0,0 +1,25 @@
From 540452f5999168de7f8efd3c3e26cc69e9f094bd Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Thu, 12 Dec 2024 11:13:16 +0800
Subject: [PATCH] add sw_64 support
---
deps/double-conversion/double-conversion/utils.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/deps/double-conversion/double-conversion/utils.h b/deps/double-conversion/double-conversion/utils.h
index 7830972..46a1a2a 100644
--- a/deps/double-conversion/double-conversion/utils.h
+++ b/deps/double-conversion/double-conversion/utils.h
@@ -77,7 +77,7 @@ inline void abort_noreturn() { abort(); }
defined(__SH4__) || defined(__alpha__) || \
defined(_MIPS_ARCH_MIPS32R2) || \
defined(__AARCH64EL__) || defined(__aarch64__) || defined(_M_ARM64) || \
- defined(__riscv) || defined(__loongarch64)
+ defined(__riscv) || defined(__loongarch64) || defined(__sw_64__)
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
#elif defined(__mc68000__)
#undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS
--
2.33.0

245
fix-CVE-2022-31116.patch Normal file
View File

@ -0,0 +1,245 @@
From 5b7674bd226198c7599c71ee3331114e5db83786 Mon Sep 17 00:00:00 2001
From: huangduirong <huangduirong@huawei.com>
Date: Sun, 26 Feb 2023 23:56:10 -0500
Subject: [PATCH] x
---
lib/ultrajson.h | 3 +-
lib/ultrajsondec.c | 73 ++++++++++++++++++----------------------------
python/JSONtoObj.c | 13 +++++++--
3 files changed, 40 insertions(+), 49 deletions(-)
diff --git a/lib/ultrajson.h b/lib/ultrajson.h
index c686bd0..3af7ca6 100644
--- a/lib/ultrajson.h
+++ b/lib/ultrajson.h
@@ -54,7 +54,6 @@ tree doesn't have cyclic references.
#define __ULTRAJSON_H__
#include <stdio.h>
-#include <wchar.h>
// Don't output any extra whitespaces when encoding
#define JSON_NO_EXTRA_WHITESPACE
@@ -316,7 +315,7 @@ EXPORTFUNCTION char *JSON_EncodeObject(JSOBJ obj, JSONObjectEncoder *enc, char *
typedef struct __JSONObjectDecoder
{
- JSOBJ (*newString)(void *prv, wchar_t *start, wchar_t *end);
+ JSOBJ (*newString)(void *prv, JSUINT32 *start, JSUINT32 *end);
void (*objectAddKey)(void *prv, JSOBJ obj, JSOBJ name, JSOBJ value);
void (*arrayAddItem)(void *prv, JSOBJ obj, JSOBJ value);
JSOBJ (*newTrue)(void *prv);
diff --git a/lib/ultrajsondec.c b/lib/ultrajsondec.c
index 05b1452..cfa3be0 100644
--- a/lib/ultrajsondec.c
+++ b/lib/ultrajsondec.c
@@ -41,7 +41,6 @@ https://opensource.apple.com/source/tcl/tcl-14/tcl/license.terms
#include <assert.h>
#include <string.h>
#include <limits.h>
-#include <wchar.h>
#include <stdlib.h>
#include <errno.h>
#include <stdint.h>
@@ -58,8 +57,8 @@ struct DecoderState
{
char *start;
char *end;
- wchar_t *escStart;
- wchar_t *escEnd;
+ JSUINT32 *escStart;
+ JSUINT32 *escEnd;
int escHeap;
int lastType;
JSUINT32 objDepth;
@@ -309,8 +308,8 @@ static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds
JSUTF16 sur[2] = { 0 };
int iSur = 0;
int index;
- wchar_t *escOffset;
- wchar_t *escStart;
+ JSUINT32 *escOffset;
+ JSUINT32 *escStart;
size_t escLen = (ds->escEnd - ds->escStart);
JSUINT8 *inputOffset;
JSUINT8 oct;
@@ -324,11 +323,11 @@ static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds
if (ds->escHeap)
{
- if (newSize > (SIZE_MAX / sizeof(wchar_t)))
+ if (newSize > (SIZE_MAX / sizeof(JSUINT32)))
{
return SetError(ds, -1, "Could not reserve memory block");
}
- escStart = (wchar_t *)ds->dec->realloc(ds->escStart, newSize * sizeof(wchar_t));
+ escStart = (JSUINT32 *)ds->dec->realloc(ds->escStart, newSize * sizeof(JSUINT32));
if (!escStart)
{
ds->dec->free(ds->escStart);
@@ -338,18 +337,18 @@ static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds
}
else
{
- wchar_t *oldStart = ds->escStart;
- if (newSize > (SIZE_MAX / sizeof(wchar_t)))
+ JSUINT32 *oldStart = ds->escStart;
+ if (newSize > (SIZE_MAX / sizeof(JSUINT32)))
{
return SetError(ds, -1, "Could not reserve memory block");
}
- ds->escStart = (wchar_t *) ds->dec->malloc(newSize * sizeof(wchar_t));
+ ds->escStart = (JSUINT32 *) ds->dec->malloc(newSize * sizeof(JSUINT32));
if (!ds->escStart)
{
return SetError(ds, -1, "Could not reserve memory block");
}
ds->escHeap = 1;
- memcpy(ds->escStart, oldStart, escLen * sizeof(wchar_t));
+ memcpy(ds->escStart, oldStart, escLen * sizeof(JSUINT32));
}
ds->escEnd = ds->escStart + newSize;
@@ -382,14 +381,14 @@ static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds
inputOffset ++;
switch (*inputOffset)
{
- case '\\': *(escOffset++) = L'\\'; inputOffset++; continue;
- case '\"': *(escOffset++) = L'\"'; inputOffset++; continue;
- case '/': *(escOffset++) = L'/'; inputOffset++; continue;
- case 'b': *(escOffset++) = L'\b'; inputOffset++; continue;
- case 'f': *(escOffset++) = L'\f'; inputOffset++; continue;
- case 'n': *(escOffset++) = L'\n'; inputOffset++; continue;
- case 'r': *(escOffset++) = L'\r'; inputOffset++; continue;
- case 't': *(escOffset++) = L'\t'; inputOffset++; continue;
+ case '\\': *(escOffset++) = '\\'; inputOffset++; continue;
+ case '\"': *(escOffset++) = '\"'; inputOffset++; continue;
+ case '/': *(escOffset++) = '/'; inputOffset++; continue;
+ case 'b': *(escOffset++) = '\b'; inputOffset++; continue;
+ case 'f': *(escOffset++) = '\f'; inputOffset++; continue;
+ case 'n': *(escOffset++) = '\n'; inputOffset++; continue;
+ case 'r': *(escOffset++) = '\r'; inputOffset++; continue;
+ case 't': *(escOffset++) = '\t'; inputOffset++; continue;
case 'u':
{
@@ -446,7 +445,7 @@ static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds
iSur ++;
break;
}
- (*escOffset++) = (wchar_t) sur[iSur];
+ (*escOffset++) = (JSUINT32) sur[iSur];
iSur = 0;
}
else
@@ -456,12 +455,9 @@ static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds
{
return SetError (ds, -1, "Unpaired high surrogate when decoding 'string'");
}
-#if WCHAR_MAX == 0xffff
- (*escOffset++) = (wchar_t) sur[0];
- (*escOffset++) = (wchar_t) sur[1];
-#else
- (*escOffset++) = (wchar_t) 0x10000 + (((sur[0] - 0xd800) << 10) | (sur[1] - 0xdc00));
-#endif
+ (*escOffset++) = (JSUINT32) sur[0];
+ (*escOffset++) = (JSUINT32) sur[1];
+ (*escOffset++) = (JSUINT32) 0x10000 + (((sur[0] - 0xd800) << 10) | (sur[1] - 0xdc00));
iSur = 0;
}
break;
@@ -475,7 +471,7 @@ static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds
case 1:
{
- *(escOffset++) = (wchar_t) (*inputOffset++);
+ *(escOffset++) = (JSUINT32) (*inputOffset++);
break;
}
@@ -489,7 +485,7 @@ static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds
}
ucs |= (*inputOffset++) & 0x3f;
if (ucs < 0x80) return SetError (ds, -1, "Overlong 2 byte UTF-8 sequence detected when decoding 'string'");
- *(escOffset++) = (wchar_t) ucs;
+ *(escOffset++) = (JSUINT32) ucs;
break;
}
@@ -512,7 +508,7 @@ static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds
}
if (ucs < 0x800) return SetError (ds, -1, "Overlong 3 byte UTF-8 sequence detected when encoding string");
- *(escOffset++) = (wchar_t) ucs;
+ *(escOffset++) = (JSUINT32) ucs;
break;
}
@@ -536,20 +532,7 @@ static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds
if (ucs < 0x10000) return SetError (ds, -1, "Overlong 4 byte UTF-8 sequence detected when decoding 'string'");
-#if WCHAR_MAX == 0xffff
- if (ucs >= 0x10000)
- {
- ucs -= 0x10000;
- *(escOffset++) = (wchar_t) (ucs >> 10) + 0xd800;
- *(escOffset++) = (wchar_t) (ucs & 0x3ff) + 0xdc00;
- }
- else
- {
- *(escOffset++) = (wchar_t) ucs;
- }
-#else
- *(escOffset++) = (wchar_t) ucs;
-#endif
+ *(escOffset++) = (JSUINT32) ucs;
break;
}
}
@@ -760,14 +743,14 @@ JSOBJ JSON_DecodeObject(JSONObjectDecoder *dec, const char *buffer, size_t cbBuf
/*
FIXME: Base the size of escBuffer of that of cbBuffer so that the unicode escaping doesn't run into the wall each time */
struct DecoderState ds;
- wchar_t escBuffer[(JSON_MAX_STACK_BUFFER_SIZE / sizeof(wchar_t))];
+ JSUINT32 escBuffer[(JSON_MAX_STACK_BUFFER_SIZE / sizeof(JSUINT32))];
JSOBJ ret;
ds.start = (char *) buffer;
ds.end = ds.start + cbBuffer;
ds.escStart = escBuffer;
- ds.escEnd = ds.escStart + (JSON_MAX_STACK_BUFFER_SIZE / sizeof(wchar_t));
+ ds.escEnd = ds.escStart + (JSON_MAX_STACK_BUFFER_SIZE / sizeof(JSUINT32));
ds.escHeap = 0;
ds.prv = dec->prv;
ds.dec = dec;
diff --git a/python/JSONtoObj.c b/python/JSONtoObj.c
index cc752a4..6dcc561 100644
--- a/python/JSONtoObj.c
+++ b/python/JSONtoObj.c
@@ -58,9 +58,18 @@ static void Object_arrayAddItem(void *prv, JSOBJ obj, JSOBJ value)
return;
}
-static JSOBJ Object_newString(void *prv, wchar_t *start, wchar_t *end)
+/*
+Check that Py_UCS4 is the same as JSUINT32, else Object_newString will fail.
+Based on Linux's check in vbox_vmmdev_types.h.
+This should be replaced with
+ _Static_assert(sizeof(Py_UCS4) == sizeof(JSUINT32));
+when C11 is made mandatory (CPython 3.11+, PyPy ?).
+*/
+typedef char assert_py_ucs4_is_jsuint32[1 - 2*!(sizeof(Py_UCS4) == sizeof(JSUINT32))];
+
+static JSOBJ Object_newString(void *prv, JSUINT32 *start, JSUINT32 *end)
{
- return PyUnicode_FromWideChar (start, (end - start));
+ return PyUnicode_FromKindAndData (PyUnicode_4BYTE_KIND, (Py_UCS4 *) start, (end - start));
}
static JSOBJ Object_newTrue(void *prv)
--
2.35.1

25
fix-CVE-2022-31117.patch Normal file
View File

@ -0,0 +1,25 @@
From a68e5b61f3df39cf998911fc87fe277436839902 Mon Sep 17 00:00:00 2001
From: huangduirong <huangduirong@huawei.com>
Date: Tue, 28 Feb 2023 08:59:16 -0500
Subject: [PATCH] x
---
lib/ultrajsondec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/ultrajsondec.c b/lib/ultrajsondec.c
index cfa3be0..3e429c6 100644
--- a/lib/ultrajsondec.c
+++ b/lib/ultrajsondec.c
@@ -330,7 +330,7 @@ static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds
escStart = (JSUINT32 *)ds->dec->realloc(ds->escStart, newSize * sizeof(JSUINT32));
if (!escStart)
{
- ds->dec->free(ds->escStart);
+ // Don't free ds->escStart here; it gets handled in JSON_DecodeObject.
return SetError(ds, -1, "Could not reserve memory block");
}
ds->escStart = escStart;
--
2.35.1

View File

@ -1,14 +1,19 @@
%global _empty_manifest_terminate_build 0
%global common_desc UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 3.6+
Name: python-ujson
Version: 4.0.2
Release: 2
Version: 5.1.0
Release: 5
Summary: Ultra fast JSON encoder and decoder for Python
License: BSD
URL: https://github.com/ultrajson/ultrajson
Source0: https://files.pythonhosted.org/packages/86/0a/80d87aa4ee79980bddabef13cb7d95de330f85355cf08dfdaf874889b02b/ujson-4.0.2.tar.gz
Source0: https://files.pythonhosted.org/packages/92/4a/2676677f59709517560b2b7eeb027453e86643d54d04687602e76cca4380/ujson-5.1.0.tar.gz
Patch0001: fix-CVE-2022-31116.patch
Patch0002: fix-CVE-2022-31117.patch
Patch0003: 0001-ujson-5.1.0-add-support-for-loongarch64.patch
Patch0004: 100-python-ujson-uos-add-sw_64-support.patch
%description
%{common_desc}
UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 3.6+
%package -n python3-ujson
Summary: Ultra fast JSON encoder and decoder for Python
@ -20,26 +25,26 @@ BuildRequires: python3-setuptools
BuildRequires: python3-pbr
BuildRequires: python3-pip
BuildRequires: python3-wheel
BuildRequires: python3-setuptools_scm
BuildRequires: python3-setuptools_scm
%description -n python3-ujson
%{common_desc}
UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 3.6+
%package help
Summary: Ultra fast JSON encoder and decoder for Python
Provides: python3-ujson-doc
BuildArch: noarch
%description help
%{common_desc}
UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 3.6+
%prep
%autosetup -n ujson-4.0.2
%autosetup -n ujson-%{version} -p1
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
@ -72,11 +77,25 @@ mv %{buildroot}/doclist.lst .
%files -n python3-ujson -f filelist.lst
%dir %{python3_sitearch}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Thu Feb 27 2025 zhangshaoning <zhangshaoning@uniontech.com> - 5.1.0-5
- Add sw_64 support
* Tue Nov 7 2023 doupengda <doupengda@loongson.cn> -5.1.0-4
- add support for loongarch64
* Wed Mar 1 2023 huangduirong <huangduirong@huawei.com> - 5.1.0-3
- fix CVE-2022-31117
* Sun Feb 26 2023 huangduirong <huangduirong@huawei.com> - 5.1.0-2
- fix CVE-2022-31116
* Wed May 18 2022 OpenStack_SIG <openstack@openeuler.org> - 5.1.0-1
- Upgrade package python3-ujson to version 5.1.0
* Thu Sep 16 2021 wangxiyuan <wangxiyuan1007@gmail.com> - 4.0.2-2
- Add gcc-c++ build require
* Tue Jul 20 2021 OpenStack_SIG <openstack@openeuler.org> - 4.0.2-1