[libsecret] egg: Fix null termination behavior of egg_secure_strndup()
- From: Daiki Ueno <dueno src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsecret] egg: Fix null termination behavior of egg_secure_strndup()
- Date: Thu, 29 Mar 2018 12:51:32 +0000 (UTC)
commit ea62c2dcda82d6f84cfd99c155bea9a2b1040ea0
Author: Daiki Ueno <dueno src gnome org>
Date: Thu Mar 29 11:30:55 2018 +0200
egg: Fix null termination behavior of egg_secure_strndup()
Even if the given string is shorter than n, the result should be null
terminated. This matches the behavior of strndup().
egg/egg-secure-memory.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/egg/egg-secure-memory.c b/egg/egg-secure-memory.c
index 8d320f1..bc82184 100644
--- a/egg/egg-secure-memory.c
+++ b/egg/egg-secure-memory.c
@@ -1344,6 +1344,7 @@ egg_secure_strndup_full (const char *tag,
len = length + 1;
res = (char *)egg_secure_alloc_full (tag, len, options);
memcpy (res, str, len);
+ res[length] = '\0';
return res;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]