[26997] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

krb5 commit: Add zapfreestr() helper to k5-int.h

daemon@ATHENA.MIT.EDU (Greg Hudson)
Mon Sep 10 12:28:56 2012

Date: Mon, 10 Sep 2012 12:28:31 -0400
From: Greg Hudson <ghudson@mit.edu>
Message-Id: <201209101628.q8AGSVmL022851@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

https://github.com/krb5/krb5/commit/0633f8317017a7d3ac4ac94c2321d20362f33653
commit 0633f8317017a7d3ac4ac94c2321d20362f33653
Author: Greg Hudson <ghudson@mit.edu>
Date:   Mon Sep 10 12:28:09 2012 -0400

    Add zapfreestr() helper to k5-int.h
    
    Since zapfree(str, strlen(str)) won't work for possibly-null values of
    str, add a helper zapfreestr() which only calls strlen() if the string
    value is non-null.

 src/include/k5-int.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/include/k5-int.h b/src/include/k5-int.h
index d119d02..670915d 100644
--- a/src/include/k5-int.h
+++ b/src/include/k5-int.h
@@ -675,6 +675,16 @@ zapfree(void *ptr, size_t len)
     }
 }
 
+/* Convenience function: zap and free zero-terminated str if it is non-NULL. */
+static inline void
+zapfreestr(void *str)
+{
+    if (str != NULL) {
+        zap(str, strlen((char *)str));
+        free(str);
+    }
+}
+
 /*
  * Combine two keys (normally used by the hardware preauth mechanism)
  */
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post