]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Avoid assertion failure in error_message
authorGreg Hudson <ghudson@mit.edu>
Thu, 16 Jan 2014 16:32:10 +0000 (11:32 -0500)
committerGreg Hudson <ghudson@mit.edu>
Fri, 17 Jan 2014 20:58:08 +0000 (15:58 -0500)
r17942 added a call to get_thread_buffer in the first part of
error_message, prior to the call to com_err_initialize.  This can
cause an assertion failure from k5_getspecific if error_message is
called on a system error before any other com_err functions are
called.  Move the initialization call earlier to prevent this.

ticket: 7822 (new)
target_version: 1.12.2
tags: pullup

src/util/et/error_message.c

index 50ede704d7759094c6fa18b2d874799ba5d21c64..fb72396ce2dee575c70c32af3071e9c047d38db2 100644 (file)
@@ -121,6 +121,9 @@ error_message(long code)
     char *cp, *cp1;
     const struct error_table *table;
 
+    if (CALL_INIT_FUNCTION(com_err_initialize))
+        return 0;
+
     l_offset = (unsigned long)code & ((1<<ERRCODE_RANGE)-1);
     offset = l_offset;
     table_num = ((unsigned long)code - l_offset) & ERRCODE_MAX;
@@ -155,8 +158,6 @@ error_message(long code)
         goto oops;
     }
 
-    if (CALL_INIT_FUNCTION(com_err_initialize))
-        return 0;
     k5_mutex_lock(&et_list_lock);
     dprintf(("scanning list for %x\n", table_num));
     for (e = et_list; e != NULL; e = e->next) {