diff options
author | Jakob Kaivo <jkk@ung.org> | 2024-06-11 13:44:21 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2024-06-11 13:44:21 -0400 |
commit | 4f29706128f3d3a66f0503d07c4960d4021aaf27 (patch) | |
tree | 7f76ae1b7819b99756feb1daf93cfe31d5c41c3b /src/string/strcpy_s.c | |
parent | 523944d96e11bde68bf9bcf8e42b7ebc99c5ed3d (diff) |
support watching for dangerous parameter accessnon-posix
Diffstat (limited to 'src/string/strcpy_s.c')
-rw-r--r-- | src/string/strcpy_s.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/string/strcpy_s.c b/src/string/strcpy_s.c index 1e3546f2..c38ebfb5 100644 --- a/src/string/strcpy_s.c +++ b/src/string/strcpy_s.c @@ -8,9 +8,15 @@ errno_t strcpy_s(char * restrict s1, rsize_t s1max, const char * restrict s2) SIGNAL_SAFE(0); ASSERT_NONNULL(s1); ASSERT_NONNULL(s2); - ASSERT_NOOVERLAP(s1, s1max, s2, strlen(s2)); + DANGEROUS_READ(s2, -1); + size_t len = strlen(s2); + ASSERT_NOOVERLAP(s1, s1max, s2, len); + DANGEROUS_WRITE(s1, s1max); strncpy(s1, s2, strlen(s2)); + + DANGER_OVER(); + return 0; } |