Comments (4)
See the documentation of these functions. E.g.
https://rurban.github.io/safeclib/doc/safec-3.1/d8/d3c/snprintf__s_8c.html
Instead of being printed, the content is stored in dest. More than dmax - 1 characters might be written, so this variant is unsafe! Always use sprintf_s instead.
With truncation the final \0 might get lost.
from safeclib.
sprintf_s(char * restrict dest, rsize_t dmax, const char * restrict fmt, ...)
snprintf_s(char * restrict dest, rsize_t dmax, const char * restrict fmt, ...)
So you mean sprintf_s is more safer than snprintf_s, because sprintf_s checks argument length should less than dmax, but snprintf_s has no check for it, if argument length is greater than dmax, null-terminated will be lost, right?
from safeclib.
exactly
from safeclib.
I made the 4 truncating versions now safe, putting a \0 at the end when truncating. See #52
from safeclib.
Related Issues (20)
- getenv_s() not allowing a null destination? HOT 4
- 3.6: build fails with gcc 12.0.0 HOT 1
- Compiler warnings in test suite with 3.7-pre on macOS Big Sur with Apple clang version 11.0.0 (clang-1100.0.33.17) HOT 1
- Test failures in test suite with 3.7-pre on macOS Big Sur with Apple clang version 11.0.0 (clang-1100.0.33.17) — no wget HOT 1
- build fail on powerpc: uint64 HOT 1
- single header file? HOT 1
- Arm64 compilation has incorrect assembly instructions HOT 3
- fix Cirrus CI HOT 1
- `getenv_s` calls error handler for "normal" errors HOT 3
- fix new mingw64 tmpfile_s error
- Setting sl_default_handler to abort_handler_s before runtime HOT 4
- fprintf_s printing NULL characters to file HOT 2
- check strpbrk_s for slen overflow or early exit with small slen
- s,handle_str_bos_overload,handle_str_bos_overflow,
- add n2809: thrd_set_constraint_handler_s HOT 1
- getenv_s problems with NULL terminator? HOT 3
- dont set errno = 0 HOT 1
- It's "`NUL` terminated"..... HOT 3
- Using safeclib with vxWorks HOT 1
- Is it "safe" to have large values of RSIZE_MAX_MEM? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from safeclib.