pull/25/head
parent
cf29b3d853
commit
0c7f9f1ed5
@ -0,0 +1,11 @@
|
||||
graphengine_add_pkg(securec
|
||||
VER 1.1.10
|
||||
URL https://gitee.com/openeuler/bounds_checking_function/repository/archive/v1.1.10?format=tar.gz
|
||||
MD5 0782dd2351fde6920d31a599b23d8c91
|
||||
LIBS c_sec
|
||||
PATCHES ${GE_SOURCE_DIR}/third_party/patch/securec/securec.patch001
|
||||
CMAKE_OPTION " "
|
||||
)
|
||||
include_directories(${securec_INC})
|
||||
file(COPY ${securec_INC}/../lib/libc_sec.so DESTINATION ${CMAKE_SOURCE_DIR}/build/graphengine)
|
||||
add_library(graphengine::securec ALIAS securec::c_sec)
|
@ -0,0 +1,23 @@
|
||||
diff -Npur bounds_checking_function/CMakeLists.txt securec/CMakeLists.txt
|
||||
--- bounds_checking_function/CMakeLists.txt 1970-01-01 08:00:00.000000000 +0800
|
||||
+++ securec/CMakeLists.txt 2020-05-11 17:10:49.406735400 +0800
|
||||
@@ -0,0 +1,19 @@
|
||||
+cmake_minimum_required(VERSION 3.14)
|
||||
+project(Securec)
|
||||
+set(CMAKE_BUILD_TYPE "Debug")
|
||||
+set(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -fPIC -O0 -Wall -Wno-deprecated-declarations -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer -D_LIBCPP_INLINE_VISIBILITY='' -D'_LIBCPP_EXTERN_TEMPLATE(...)='")
|
||||
+set(CMAKE_C_FLAGS_RELEASE "$ENV{CFLAGS} -fPIC -O3 -Wall -Wno-deprecated-declarations")
|
||||
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
+
|
||||
+#add flags
|
||||
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include -Werror")
|
||||
+
|
||||
+include_directories(./include)
|
||||
+aux_source_directory(./src SECUREC_SRCS)
|
||||
+add_library(c_sec SHARED ${SECUREC_SRCS})
|
||||
+
|
||||
+install(TARGETS c_sec
|
||||
+ DESTINATION lib)
|
||||
+install(FILES "./include/securec.h"
|
||||
+ "./include/securectype.h"
|
||||
+ DESTINATION include)
|
Binary file not shown.
@ -1,11 +0,0 @@
|
||||
SET(CMAKE_BUILD_TYPE "Debug")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -fPIC -O0 -Wall -Wno-deprecated-declarations -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer -D_LIBCPP_INLINE_VISIBILITY='' -D'_LIBCPP_EXTERN_TEMPLATE(...)='")
|
||||
SET(CMAKE_C_FLAGS_RELEASE "$ENV{CFLAGS} -fPIC -O3 -Wall -Wno-deprecated-declarations")
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
#add flags
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include -Werror")
|
||||
|
||||
|
||||
include_directories(./include)
|
||||
add_subdirectory(src)
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,3 +0,0 @@
|
||||
aux_source_directory(. SECUREC_SRCS)
|
||||
|
||||
add_library(securec STATIC ${SECUREC_SRCS})
|
@ -1,56 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "securec.h"
|
||||
|
||||
/*
|
||||
* <FUNCTION DESCRIPTION>
|
||||
* The fscanf_s function is equivalent to fscanf except that the c, s,
|
||||
* and [ conversion specifiers apply to a pair of arguments (unless assignment suppression is indicated by a*)
|
||||
* The fscanf function reads data from the current position of stream into
|
||||
* the locations given by argument (if any). Each argument must be a pointer
|
||||
* to a variable of a type that corresponds to a type specifier in format.
|
||||
* format controls the interpretation of the input fields and has the same
|
||||
* form and function as the format argument for scanf.
|
||||
*
|
||||
* <INPUT PARAMETERS>
|
||||
* stream Pointer to FILE structure.
|
||||
* format Format control string, see Format Specifications.
|
||||
* ... Optional arguments.
|
||||
*
|
||||
* <OUTPUT PARAMETERS>
|
||||
* ... The convered value stored in user assigned address
|
||||
*
|
||||
* <RETURN VALUE>
|
||||
* Each of these functions returns the number of fields successfully converted
|
||||
* and assigned; the return value does not include fields that were read but
|
||||
* not assigned. A return value of 0 indicates that no fields were assigned.
|
||||
* return -1 if an error occurs.
|
||||
*/
|
||||
int fscanf_s(FILE *stream, const char *format, ...)
|
||||
{
|
||||
int ret; /* If initialization causes e838 */
|
||||
va_list argList;
|
||||
|
||||
va_start(argList, format);
|
||||
ret = vfscanf_s(stream, format, argList);
|
||||
va_end(argList);
|
||||
(void)argList; /* to clear e438 last value assigned not used , the compiler will optimize this code */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "securec.h"
|
||||
|
||||
/*
|
||||
* <FUNCTION DESCRIPTION>
|
||||
* The fwscanf_s function is the wide-character equivalent of the fscanf_s function
|
||||
* The fwscanf_s function reads data from the current position of stream into
|
||||
* the locations given by argument (if any). Each argument must be a pointer
|
||||
* to a variable of a type that corresponds to a type specifier in format.
|
||||
* format controls the interpretation of the input fields and has the same
|
||||
* form and function as the format argument for scanf.
|
||||
*
|
||||
* <INPUT PARAMETERS>
|
||||
* stream Pointer to FILE structure.
|
||||
* format Format control string, see Format Specifications.
|
||||
* ... Optional arguments.
|
||||
*
|
||||
* <OUTPUT PARAMETERS>
|
||||
* ... The converted value stored in user assigned address
|
||||
*
|
||||
* <RETURN VALUE>
|
||||
* Each of these functions returns the number of fields successfully converted
|
||||
* and assigned; the return value does not include fields that were read but
|
||||
* not assigned. A return value of 0 indicates that no fields were assigned.
|
||||
* return -1 if an error occurs.
|
||||
*/
|
||||
int fwscanf_s(FILE *stream, const wchar_t *format, ...)
|
||||
{
|
||||
int ret; /* If initialization causes e838 */
|
||||
va_list argList;
|
||||
|
||||
va_start(argList, format);
|
||||
ret = vfwscanf_s(stream, format, argList);
|
||||
va_end(argList);
|
||||
(void)argList; /* to clear e438 last value assigned not used , the compiler will optimize this code */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1,75 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "securecutil.h"
|
||||
|
||||
static void SecTrimCRLF(char *buffer, size_t len)
|
||||
{
|
||||
int i;
|
||||
/* No need to determine whether integer overflow exists */
|
||||
for (i = (int)(len - 1); i >= 0 && (buffer[i] == '\r' || buffer[i] == '\n'); --i) {
|
||||
buffer[i] = '\0';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* <FUNCTION DESCRIPTION>
|
||||
* The gets_s function reads at most one less than the number of characters
|
||||
* specified by destMax from the stream pointed to by stdin, into the array pointed to by buffer
|
||||
* The line consists of all characters up to and including
|
||||
* the first newline character ('\n'). gets_s then replaces the newline
|
||||
* character with a null character ('\0') before returning the line.
|
||||
* If the first character read is the end-of-file character, a null character
|
||||
* is stored at the beginning of buffer and NULL is returned.
|
||||
*
|
||||
* <INPUT PARAMETERS>
|
||||
* buffer Storage location for input string.
|
||||
* numberOfElements The size of the buffer.
|
||||
*
|
||||
* <OUTPUT PARAMETERS>
|
||||
* buffer is updated
|
||||
*
|
||||
* <RETURN VALUE>
|
||||
* buffer Successful operation
|
||||
* NULL Improper parameter or read fail
|
||||
*/
|
||||
char *gets_s(char *buffer, size_t numberOfElements)
|
||||
{
|
||||
size_t len;
|
||||
#ifdef SECUREC_COMPATIBLE_WIN_FORMAT
|
||||
size_t bufferSize = ((numberOfElements == (size_t)-1) ? SECUREC_STRING_MAX_LEN : numberOfElements);
|
||||
#else
|
||||
size_t bufferSize = numberOfElements;
|
||||
#endif
|
||||
|
||||
if (buffer == NULL || bufferSize == 0 || bufferSize > SECUREC_STRING_MAX_LEN) {
|
||||
SECUREC_ERROR_INVALID_PARAMTER("gets_s");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fgets(buffer, (int)bufferSize, stdin) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = strlen(buffer);
|
||||
if (len > 0 && len < bufferSize) {
|
||||
SecTrimCRLF(buffer, len);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue