commit
56b7410331
BIN
OpenCC-ver.1.0.5.tar.gz
Normal file
BIN
OpenCC-ver.1.0.5.tar.gz
Normal file
Binary file not shown.
35
opencc-check-bounds.patch
Normal file
35
opencc-check-bounds.patch
Normal file
@ -0,0 +1,35 @@
|
||||
Index: OpenCC-ver.1.0.5/src/BinaryDict.cpp
|
||||
===================================================================
|
||||
--- OpenCC-ver.1.0.5.orig/src/BinaryDict.cpp
|
||||
+++ OpenCC-ver.1.0.5/src/BinaryDict.cpp
|
||||
@@ -63,6 +63,12 @@ void BinaryDict::SerializeToFile(FILE* f
|
||||
}
|
||||
|
||||
BinaryDictPtr BinaryDict::NewFromFile(FILE* fp) {
|
||||
+ size_t offsetBound, savedOffset;
|
||||
+ savedOffset = ftell(fp);
|
||||
+ fseek(fp, 0L, SEEK_END);
|
||||
+ offsetBound = ftell(fp) - savedOffset;
|
||||
+ fseek(fp, savedOffset, SEEK_SET);
|
||||
+
|
||||
BinaryDictPtr dict(new BinaryDict(LexiconPtr(new Lexicon)));
|
||||
|
||||
// Number of items
|
||||
@@ -109,7 +115,7 @@ BinaryDictPtr BinaryDict::NewFromFile(FI
|
||||
// Key offset
|
||||
size_t keyOffset;
|
||||
unitsRead = fread(&keyOffset, sizeof(size_t), 1, fp);
|
||||
- if (unitsRead != 1) {
|
||||
+ if (unitsRead != 1 || keyOffset >= offsetBound) {
|
||||
throw InvalidFormat("Invalid OpenCC binary dictionary (keyOffset)");
|
||||
}
|
||||
const char* key = dict->keyBuffer.c_str() + keyOffset;
|
||||
@@ -118,7 +124,7 @@ BinaryDictPtr BinaryDict::NewFromFile(FI
|
||||
for (size_t j = 0; j < numValues; j++) {
|
||||
size_t valueOffset;
|
||||
unitsRead = fread(&valueOffset, sizeof(size_t), 1, fp);
|
||||
- if (unitsRead != 1) {
|
||||
+ if (unitsRead != 1 || valueOffset >= offsetBound) {
|
||||
throw InvalidFormat("Invalid OpenCC binary dictionary (valueOffset)");
|
||||
}
|
||||
const char* value = dict->valueBuffer.c_str() + valueOffset;
|
||||
26
opencc-fixes-cmake.patch
Normal file
26
opencc-fixes-cmake.patch
Normal file
@ -0,0 +1,26 @@
|
||||
Index: OpenCC-ver.1.0.5/CMakeLists.txt
|
||||
===================================================================
|
||||
--- OpenCC-ver.1.0.5.orig/CMakeLists.txt
|
||||
+++ OpenCC-ver.1.0.5/CMakeLists.txt
|
||||
@@ -68,7 +68,7 @@ set (DIR_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
set (DIR_INCLUDE ${DIR_PREFIX}/include/)
|
||||
set (DIR_SHARE ${DIR_PREFIX}/share/)
|
||||
set (DIR_ETC ${DIR_PREFIX}/etc/)
|
||||
-set (DIR_LIBRARY ${DIR_PREFIX}/lib${LIB_SUFFIX}/)
|
||||
+set (DIR_LIBRARY ${LIB_INSTALL_DIR})
|
||||
|
||||
if (DEFINED SHARE_INSTALL_PREFIX)
|
||||
set (DIR_SHARE ${SHARE_INSTALL_PREFIX})
|
||||
Index: OpenCC-ver.1.0.5/data/CMakeLists.txt
|
||||
===================================================================
|
||||
--- OpenCC-ver.1.0.5.orig/data/CMakeLists.txt
|
||||
+++ OpenCC-ver.1.0.5/data/CMakeLists.txt
|
||||
@@ -1,6 +1,6 @@
|
||||
set(OPENCC_DICT_BIN opencc_dict)
|
||||
-set(DICT_MERGE_BIN python ${CMAKE_CURRENT_SOURCE_DIR}/scripts/merge.py)
|
||||
-set(DICT_REVERSE_BIN python ${CMAKE_CURRENT_SOURCE_DIR}/scripts/reverse.py)
|
||||
+set(DICT_MERGE_BIN python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/merge.py)
|
||||
+set(DICT_REVERSE_BIN python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/reverse.py)
|
||||
set(DICT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dictionary)
|
||||
set(DICT_GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
71
opencc.spec
Normal file
71
opencc.spec
Normal file
@ -0,0 +1,71 @@
|
||||
Name: opencc
|
||||
Version: 1.0.5
|
||||
Release: 4
|
||||
Summary: Simplified Chinese Traditional Conversion Library
|
||||
License: ASL 2.0
|
||||
URL: https://github.com/BYVoid/OpenCC
|
||||
Source0: https://github.com/BYVoid/OpenCC/archive/ver.%{version}.tar.gz#/OpenCC-ver.%{version}.tar.gz
|
||||
Patch0001: opencc-fixes-cmake.patch
|
||||
Patch0002: opencc-check-bounds.patch
|
||||
|
||||
Provides: %{name}-tools = %{version}-%{release}
|
||||
Obsoletes: %{name}-tools < %{version}-%{release}
|
||||
BuildRequires: gcc-c++ gettext cmake doxygen python3
|
||||
|
||||
%description
|
||||
Opencc is for between Traditional Chinese and Simplified Chinese characters and phrases conversion library.
|
||||
|
||||
%package devel
|
||||
Summary: Development files for OpenCC
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
|
||||
%description devel
|
||||
This package contains libraries and header files for developing applications that use opencc.
|
||||
|
||||
%package help
|
||||
Summary: Documentation for opencc
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
Provides: %{name}-doc = %{version}-%{release}
|
||||
Obsoletes: %{name}-doc < %{version}-%{release}
|
||||
|
||||
%description help
|
||||
This package provides documentation for opencc.
|
||||
|
||||
%prep
|
||||
%autosetup -n OpenCC-ver.%{version} -p1
|
||||
|
||||
%build
|
||||
%cmake . -DENABLE_GETTEXT:BOOL=ON -DBUILD_DOCUMENTATION:BOOL=ON
|
||||
%make_build VERBOSE=1
|
||||
|
||||
%install
|
||||
%make_install
|
||||
|
||||
%check
|
||||
ctest
|
||||
|
||||
%post
|
||||
/sbin/ldconfig
|
||||
|
||||
%postun
|
||||
/sbin/ldconfig
|
||||
|
||||
%files
|
||||
%doc AUTHORS LICENSE README.md
|
||||
%{_libdir}/lib*.so.*
|
||||
%{_datadir}/opencc/
|
||||
%{_bindir}/*
|
||||
%exclude %{_datadir}/opencc/doc
|
||||
%exclude %{_libdir}/*.a
|
||||
|
||||
%files devel
|
||||
%{_includedir}/*
|
||||
%{_libdir}/*.so
|
||||
%{_libdir}/pkgconfig/*.pc
|
||||
|
||||
%files help
|
||||
%{_datadir}/opencc/doc
|
||||
|
||||
%changelog
|
||||
* Thu Dec 12 2019 fengbing <fengbing7@huawei.com> - 1.0.5-4
|
||||
- Package init
|
||||
Loading…
x
Reference in New Issue
Block a user