Comments (6)
memset_s documents the different behavior if under C11:
Since C11 smax=0 is allowed, before it fails with ESZEROL.
So we'll have to check for C11 (added a compile-time configure probe)
On C11 allow smax/n=0, before keep the old behavior: ESZEROL. Good?
from safeclib.
I don't care that much about the perf. issue, but about convenience and conformance, analog to free(NULL)
(supporting your point).
I'll check how prior art (MSVC) does it, when the standard does not mention it.
And this code was in production at Cisco since 2008, so changing might be disruptive.
Using memcpy_s over memcpy might suggest erroring on a 0 length argument. i.e. a security feature. (keeping it asis)
from safeclib.
In MSVC and wine/ReactOS smax=0 is valid: https://msdn.microsoft.com/en-us/library/wes2t00f.aspx
from safeclib.
fixed in d453998.
from safeclib.
@rurban since you now have a HAVE_C11
and WANT_C11
I was a little confused about the difference until I researched it. So I'd suggest renaming WANT_C11
to WANT_C11_ANNEXK
or WANT_C11_LIB_EXT1
to make it clearer that you're wanting a subset/extension instead of wanting to use the C11 base standard.
But at that point why not just use #if __STDC_WANT_LIB_EXT1__ >= 1
everywhere so you're not using a custom symbol?
from safeclib.
I admit it's confusing at the first glance.
But I'd rather stay with the short form. It's only used in a few places where the actual upstream code is usable (memset_s
on darwin).
WANT_C11
means #if __STDC_WANT_LIB_EXT1__ >= 1
, yes. But we would need to use the long form #if defined(__STDC_WANT_LIB_EXT1__) && (__STDC_WANT_LIB_EXT1__ >= 1)
The idea of safec is to implement C11 fully. Other's say they do, but they don't. Having this discrepancy, I think it's easier to make it clear with this short name.
I don't want to emphasis it as extension, safe functions must be the default. Microsoft even warns all users to switch over to the safe variants.
from safeclib.
Related Issues (20)
- 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
- Compiling on Apple M1/M2/M3 HOT 2
- Release 3.8.0? HOT 1
- Build issue on RHEL 8.6 HOT 1
- Implicit declaration of fileno in vfprintf_s.c HOT 4
- CMake support? HOT 1
- Non-portable format strings HOT 4
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.