Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jbenner-radham/libsafec-strnlen_s

A header only implementation of "strnlen_s" from C11 - Annex K forked from libsafec (Safe C Library).
https://github.com/jbenner-radham/libsafec-strnlen_s

annex-k bounds-checking c11 safety secure-coding strnlen-s

Last synced: about 2 months ago
JSON representation

A header only implementation of "strnlen_s" from C11 - Annex K forked from libsafec (Safe C Library).

Awesome Lists containing this project

README

        

# libsafec - strnlen_s

### Synopsis

```c
#include "strnlen_s.h"

size_t strnlen_s(const char *s, size_t maxsize);
```

### Description

The `strnlen_s` function computes the length of the string pointed to by `s`.

### Specified In

ISO/IEC TR 24731-1 §6.7.4.3, Programming languages, environments and system software
interfaces, Extensions to the C Library, Part I: Bounds-checking interfaces.

### Input Parameters

- `s` pointer to string
- `maxsize` restricted maximum length.

### Output Parameters

none

### Runtime Constraints

none

### Returns

If `s` is a null pointer, then the `strnlen_s` function returns zero.

Otherwise, the `strnlen_s` function returns the number of characters that precede the terminating null character. If there is no null character in the first `maxsize` characters of `s` then `strnlen_s` returns `maxsize`. At most the first `maxsize` characters of `s` shall be accessed by `strnlen_s`.