Giter Club home page Giter Club logo

slibc's Introduction

slibc

Introduction

This library provides an implementation of the bounds-checking C functions (as specified in Annex K of the current C standard, a.k.a. C11) for use with the GNU C library.

These functions lower the risk of introducing security vulnerabilities such as buffer overflows and format string vulnerabilities into your code by providing clear and easy-to-use interfaces. For each C function a secure alternate function ending in a _s postfix is provided (e.g., strcpy_s). Use of these functions is recommended by security experts and secure coding standards (CERT Secure Coding Standard C).

This library consists of:

  • a thread-safe implementation of all functions specified in the ISO Standard (except widechar functions)
  • API documentation for all functions
  • test cases for all functions
  • overloaded C++ template functions for easier use when compiling with g++

How to compile the library

  1. Compile the slibc libary by typing make. Slibc is compiled as a shared library (libslibc.so). To link with the shared library, add -lslibc to your linker step.
  2. Optionally run all tests by executing make test.

Use SLIBC with your program

  1. Use the new _s functions in your code:
#include <string.h>

int main(int argc, char *argv[])
{
  char dest[10];
  strcpy_s(dest, sizeof(dest), argv[0]);
}
  1. When compiling include the SLIBC header directory (include/slibc) in your compiler's include path (e.g., add -I~/slibc/include/slibc). Remember that Annex K adds functions to the standard C library by extending existing header files. SLIBC makes the fact that it's a third-party library (instead of being part of GLIBC) as transparent as possible to your program. To use strcpy_s, simply include string.h in your program. It is important that your compiler searches in the slibc header directory first.
  2. Link your program to Slibc. Slibc is built as a shared library. Add -lslibc to your linking step. Additionally, you might have to add the location of slibc's so-files to your Linker search path by adding -L (e.g., -L../src/).
  3. Run your program. If the Slibc shared object file cannot be found, you have to adjust the environment variable LD_LIBRARY_PATH.

Directory layout

  • include/slibc: contains the public header files
  • src/: contains the implementation
  • tests_slibc/: contains our c++ based test-suite for slibc
  • tests_ow/: contains the open watcom tests.

slibc's People

Contributors

mkoppmann avatar ulrichbayer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slibc's Issues

Missed runtime-constraint violation error in strtok_s

In the following code

*ptr = (char *) memchr (token, '\0', (size_t) s1max);
if *ptr == NULL then we should trigger slibc_call_constraint_handler.

Excerpt from standard:

Runtime-constraints:
The end of the token found shall occur within the first *s1max characters of s1 for the first call, and shall occur within the first *s1max characters of where searching resumes on subsequent calls

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.