diff options
author | Björn Esser <besser82@fedoraproject.org> | 2021-07-22 23:49:14 +0200 |
---|---|---|
committer | Björn Esser <besser82@fedoraproject.org> | 2021-07-22 23:49:14 +0200 |
commit | bb33c6da5a05ed7035a3ae3e62184568a51f0fb3 (patch) | |
tree | 6c095f5db275d0d3a1962b038ca8de76724e3d40 | |
parent | db97b665c1d3762587071854991894182836ffe2 (diff) | |
download | libxcrypt-bb33c6da5a05ed7035a3ae3e62184568a51f0fb3.tar.gz libxcrypt-bb33c6da5a05ed7035a3ae3e62184568a51f0fb3.tar.bz2 libxcrypt-bb33c6da5a05ed7035a3ae3e62184568a51f0fb3.zip |
test/getrandom-fallbacks.c: Fix 'STRING_NULL' found by Covscan.
CWE-170: String not null terminated (STRING_NULL)
string_null: Passing unterminated string dbuf to strcmp,
which expects a null-terminated string.
-rw-r--r-- | test/getrandom-fallbacks.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/test/getrandom-fallbacks.c b/test/getrandom-fallbacks.c index d3d7351..bd97667 100644 --- a/test/getrandom-fallbacks.c +++ b/test/getrandom-fallbacks.c @@ -255,7 +255,7 @@ main (void) char buf[257]; char expected[2] = { 0, 0 }; memset (buf, 'x', sizeof buf - 1); - buf[256] = '\0'; + buf[sizeof buf - 1] = '\0'; bool failed = false; const struct subtest *s; @@ -276,6 +276,7 @@ main (void) s++; bool r = get_random_bytes (buf, sizeof buf - 1); + buf[sizeof buf - 1] = '\0'; if ((s->expected && !r) || (!s->expected && r)) { printf ("FAIL: %s: get_random_bytes: %s\n", |