libboundscheck:基于 C11 Annex K 标准的内存字符串操作函数库项目

Enhanced safety functions

Branch1Tags3

libboundscheck

Description

  • following the standard of C11 Annex K (bound-checking interfaces), functions of the common memory/string operation classes, such as memcpy_s, strcpy_s, are selected and implemented.

  • other standard functions in C11 Annex K will be analyzed in the future and implemented in this organization if necessary.

  • handles the release, update, and maintenance of bounds_checking_function.

Function List

  • memcpy_s
  • wmemcpy_s
  • memmove_s
  • wmemmove_s
  • memset_s
  • strcpy_s
  • wcscpy_s
  • strncpy_s
  • wcsncpy_s
  • strcat_s
  • wcscat_s
  • strncat_s
  • wcsncat_s
  • strtok_s
  • wcstok_s
  • sprintf_s
  • swprintf_s
  • vsprintf_s
  • vswprintf_s
  • snprintf_s
  • vsnprintf_s
  • scanf_s
  • wscanf_s
  • vscanf_s
  • vwscanf_s
  • fscanf_s
  • fwscanf_s
  • vfscanf_s
  • vfwscanf_s
  • sscanf_s
  • swscanf_s
  • vsscanf_s
  • vswscanf_s
  • gets_s

Build

  1. General

In the code root directory (where the Makefile is), run:

make

or

make shared

The generated shared library libboundscheck.so is stored in the newly created directory lib. The shared is the default target of the Makefile. If you replace the shared argument with static, a static library will be automatically generated. Alternatively, replace it with all to generate both shared and static libraries.

  1. Advanced
  • Make and install

Use make install to install the libraries (and the headers). The following commands will compile and install to ${HOME}/.local/ by default.

make
make install

To install to a custom location, specify DESTDIR with make install. The following commands install headers and libraries to ${HOME}/my-project/third_party/libboundscheck:

make install DESTDIR=${HOME}/my-project/third_party/libboundscheck
  • Specify the compiler via the CC parameter

The following command uses gcc as the compiler:

make CC=gcc
  • Specify the target's output filename

Use the LIBBOUNDSCHECK_SHARED or LIBBOUNDSCHECK_STATIC parameters to specify the output target filename respectively:

The following command will output a shared library named libsecurec.so:

make LIBBOUNDSCHECK_SHARED=libsecurec.so

How to use

  1. Copy the libboundscheck.so to the library file directory, for example: "/usr/local/lib/".

  2. To use the libboundscheck, add the “-lboundscheck” parameters to the compiler, for example: “gcc -g -o test test.c -lboundscheck”.

Introduction

Enhanced safety functions

Customize your domain