Blame SOURCES/nuxwdog-heisen-memory-bug.patch

7ba072
From 63d0cb4948d240068be52c5b0f701a9524320d4d Mon Sep 17 00:00:00 2001
7ba072
From: Dinesh Prasanth M K <dmoluguw@redhat.com>
7ba072
Date: Thu, 16 Aug 2018 12:23:31 -0400
7ba072
Subject: [PATCH] Fixing memory issue in NHSM-OCS
7ba072
7ba072
This fixes the heisen memory bug
7ba072
https://pagure.io/nuxwdog/issue/8
7ba072
7ba072
Signed-off-by: Dinesh Prasanth M K <dmoluguw@redhat.com>
7ba072
---
7ba072
 src/com/redhat/nuxwdog/wdpwd.cpp | 6 +++---
7ba072
 1 file changed, 3 insertions(+), 3 deletions(-)
7ba072
7ba072
diff --git a/src/com/redhat/nuxwdog/wdpwd.cpp b/src/com/redhat/nuxwdog/wdpwd.cpp
7ba072
index 1ff7829..09191fc 100644
7ba072
--- a/src/com/redhat/nuxwdog/wdpwd.cpp
7ba072
+++ b/src/com/redhat/nuxwdog/wdpwd.cpp
7ba072
@@ -111,7 +111,7 @@ watchdog_pwd_encrypt(char *pwdvalue, pwdenc_t *pwdcrypt)
7ba072
 
7ba072
     int len = strlen(pwdvalue);
7ba072
     {
7ba072
-        if ((pwdcrypt->ptr = (void *)malloc(len)) == NULL)
7ba072
+        if ((pwdcrypt->ptr = (void *)malloc(len + 1)) == NULL)
7ba072
             return;
7ba072
     
7ba072
         pwdcrypt->len = len;
7ba072
@@ -247,7 +247,7 @@ int watchdog_pwd_save(char *pwdname, int serial, char *pwdvalue)
7ba072
              * Already have this password saved, so server must be
7ba072
              * reprompting.  Replace the old value with the new value.
7ba072
              */
7ba072
-            char *keyname = (char *) malloc(strlen(pwdname) + strlen(KEY_PREFIX));
7ba072
+            char *keyname = (char *) malloc(strlen(pwdname) + strlen(KEY_PREFIX) + 1);
7ba072
             sprintf(keyname, "%s%s", KEY_PREFIX, pwdname);
7ba072
             pwdp->pwdserial = add_key("user", keyname, (void *) pwdvalue,
7ba072
                 strlen(pwdvalue), KEY_SPEC_PROCESS_KEYRING);
7ba072
@@ -270,7 +270,7 @@ int watchdog_pwd_save(char *pwdname, int serial, char *pwdvalue)
7ba072
     pwdp->pwdname = strdup(pwdname);
7ba072
     pwdp->serial = serial;
7ba072
 
7ba072
-    char *keyname = (char *) malloc(strlen(pwdname) + strlen(KEY_PREFIX));
7ba072
+    char *keyname = (char *) malloc(strlen(pwdname) + strlen(KEY_PREFIX) + 1);
7ba072
     sprintf(keyname, "%s%s", KEY_PREFIX, pwdname);
7ba072
     pwdp->pwdserial = add_key("user", keyname, (void *) pwdvalue,
7ba072
         strlen(pwdvalue), KEY_SPEC_PROCESS_KEYRING);
7ba072
-- 
7ba072
2.14.4
7ba072