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

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

krb5 commit [krb5-1.9]: Avoid side effects in assert expressions

daemon@ATHENA.MIT.EDU (Tom Yu)
Tue Apr 23 17:19:28 2013

Date: Tue, 23 Apr 2013 17:19:23 -0400
From: Tom Yu <tlyu@mit.edu>
Message-Id: <201304232119.r3NLJNhw029548@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/021eb1fd74dbff614b3760cecde86c7e6ec5ae7f
commit 021eb1fd74dbff614b3760cecde86c7e6ec5ae7f
Author: Tom Yu <tlyu@mit.edu>
Date:   Mon Apr 22 19:02:56 2013 -0400

    Avoid side effects in assert expressions
    
    asserts may be compiled out with -DNDEBUG, so it's wrong to use an
    assert expression with an important side effect.
    
    (We also have scores of side-effecting asserts in test programs, but
    those are less important and can be dealt with separately.)
    
    (back ported from commit 221cd4a23691601a14500bc00146c265b50bdc94)
    
    ticket: 7614 (new)
    version_fixed: 1.9.5
    status: resolved

 src/lib/crypto/krb/cf2.c |    3 ++-
 src/util/et/com_err.c    |   12 ++++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/lib/crypto/krb/cf2.c b/src/lib/crypto/krb/cf2.c
index ab0a134..29e59d0 100644
--- a/src/lib/crypto/krb/cf2.c
+++ b/src/lib/crypto/krb/cf2.c
@@ -112,7 +112,8 @@ krb5_c_fx_cf2_simple(krb5_context context,
         return KRB5_BAD_ENCTYPE;
     out_enctype_num = k1->enctype;
     assert(out != NULL);
-    assert((out_enctype = find_enctype(out_enctype_num)) != NULL);
+    out_enctype = find_enctype(out_enctype_num);
+    assert(out_enctype != NULL);
     if (out_enctype->prf == NULL) {
         if (context)
             krb5int_set_error(&(context->err), KRB5_CRYPTO_INTERNAL,
diff --git a/src/util/et/com_err.c b/src/util/et/com_err.c
index aaba897..96922ec 100644
--- a/src/util/et/com_err.c
+++ b/src/util/et/com_err.c
@@ -154,8 +154,10 @@ et_old_error_hook_func set_com_err_hook (et_old_error_hook_func new_proc)
     et_old_error_hook_func x;
 
     /* Broken initialization?  What can we do?  */
-    assert(com_err_finish_init() == 0);
-    assert(com_err_lock_hook_handle() == 0);
+    if (com_err_finish_init() != 0)
+        abort();
+    if (com_err_lock_hook_handle() != 0)
+        abort();
     x = com_err_hook;
     com_err_hook = new_proc;
     k5_mutex_unlock(&com_err_hook_lock);
@@ -167,8 +169,10 @@ et_old_error_hook_func reset_com_err_hook ()
     et_old_error_hook_func x;
 
     /* Broken initialization?  What can we do?  */
-    assert(com_err_finish_init() == 0);
-    assert(com_err_lock_hook_handle() == 0);
+    if (com_err_finish_init() != 0)
+        abort();
+    if (com_err_lock_hook_handle() != 0)
+        abort();
     x = com_err_hook;
     com_err_hook = NULL;
     k5_mutex_unlock(&com_err_hook_lock);
_______________________________________________
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