[gnome-keyring] Fix issue found by address sanitizer
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring] Fix issue found by address sanitizer
- Date: Wed, 12 Aug 2015 12:06:13 +0000 (UTC)
commit 760f60931a13c6c422a09dca47eb8cb69898d0ec
Author: Milan Crha <mcrha redhat com>
Date: Thu Aug 6 12:04:00 2015 +0000
Fix issue found by address sanitizer
There was done a read of one item more than the array was allocated.
This patch fixes the issue.
https://bugzilla.gnome.org/show_bug.cgi?id=752919
pkcs11/rpc-layer/gkm-rpc-util.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/pkcs11/rpc-layer/gkm-rpc-util.c b/pkcs11/rpc-layer/gkm-rpc-util.c
index 340baf7..e7d5a61 100644
--- a/pkcs11/rpc-layer/gkm-rpc-util.c
+++ b/pkcs11/rpc-layer/gkm-rpc-util.c
@@ -81,9 +81,10 @@ gkm_rpc_mechanism_list_purge (CK_MECHANISM_TYPE_PTR mechs, CK_ULONG* n_mechs)
for (i = 0; i < (int)(*n_mechs); ++i) {
if (!gkm_rpc_mechanism_has_no_parameters (mechs[i]) &&
!gkm_rpc_mechanism_has_sane_parameters (mechs[i])) {
-
- /* Remove the mechanism from the list */
- memmove (&mechs[i], &mechs[i + 1], (*n_mechs - i) * sizeof (CK_MECHANISM_TYPE));
+ if (*n_mechs - i - 1 > 0) {
+ /* Remove the mechanism from the list */
+ memmove (&mechs[i], &mechs[i + 1], (*n_mechs - i - 1) * sizeof
(CK_MECHANISM_TYPE));
+ }
--(*n_mechs);
--i;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]