~ubuntu-branches/ubuntu/natty/libgcrypt11/natty-proposed

« back to all changes in this revision

Viewing changes to src/misc.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2009-02-21 13:46:58 UTC
  • mto: (1.1.6 upstream) (2.1.3 squeeze)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20090221134658-855twvcr4ezk2ron
ImportĀ upstreamĀ versionĀ 1.4.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* misc.c
2
 
 * Copyright (C) 1999, 2001, 2002, 2003, 2007 Free Software Foundation, Inc.
 
2
 * Copyright (C) 1999, 2001, 2002, 2003, 2007, 
 
3
 *               2008 Free Software Foundation, Inc.
3
4
 *
4
5
 * This file is part of Libgcrypt.
5
6
 *
75
76
  if ( !text ) /* get a default text */
76
77
    text = gpg_strerror (rc);
77
78
 
78
 
  if (fatal_error_handler)
 
79
  if (fatal_error_handler && !fips_mode () )
79
80
    fatal_error_handler (fatal_error_handler_value, rc, text);
80
81
 
 
82
  fips_signal_fatal_error (text);
81
83
  write2stderr("\nFatal error: ");
82
84
  write2stderr(text);
83
85
  write2stderr("\n");
132
134
  
133
135
  if ( level == GCRY_LOG_FATAL || level == GCRY_LOG_BUG )
134
136
    {
 
137
      fips_signal_fatal_error ("internal error (fatal or bug)");
135
138
      _gcry_secmem_term ();
136
139
      abort ();
137
140
    }
149
152
}
150
153
 
151
154
 
152
 
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
 
155
#if defined(JNLIB_GCC_M_FUNCTION) || __STDC_VERSION__ >= 199901L
153
156
void
154
157
_gcry_bug( const char *file, int line, const char *func )
155
158
{
157
160
             ("... this is a bug (%s:%d:%s)\n"), file, line, func );
158
161
    abort(); /* never called, but it makes the compiler happy */
159
162
}
 
163
void
 
164
_gcry_assert_failed (const char *expr, const char *file, int line,
 
165
                     const char *func)
 
166
{
 
167
  _gcry_log (GCRY_LOG_BUG,
 
168
             ("Assertion `%s' failed (%s:%d:%s)\n"), expr, file, line, func );
 
169
  abort(); /* Never called, but it makes the compiler happy. */
 
170
}
160
171
#else
161
172
void
162
173
_gcry_bug( const char *file, int line )
165
176
             _("you found a bug ... (%s:%d)\n"), file, line);
166
177
    abort(); /* never called, but it makes the compiler happy */
167
178
}
 
179
void
 
180
_gcry_assert_failed (const char *expr, const char *file, int line)
 
181
{
 
182
  _gcry_log (GCRY_LOG_BUG,
 
183
             ("Assertion `%s' failed (%s:%d)\n"), expr, file, line);
 
184
  abort(); /* Never called, but it makes the compiler happy. */
 
185
}
168
186
#endif
169
187
 
170
188
void
232
250
    va_end(arg_ptr);
233
251
}
234
252
 
 
253
 
235
254
void
236
255
_gcry_log_printf (const char *fmt, ...)
237
256
{
245
264
    }
246
265
}
247
266
 
 
267
/* Print a hexdump of BUFFER.  With TEXT of NULL print just the raw
 
268
   dump, with TEXT an empty string, print a trailing linefeed,
 
269
   otherwise print an entire debug line. */
 
270
void
 
271
_gcry_log_printhex (const char *text, const void *buffer, size_t length)
 
272
{
 
273
  if (text && *text)
 
274
    log_debug ("%s ", text);
 
275
  if (length)
 
276
    {
 
277
      const unsigned char *p = buffer;
 
278
      log_printf ("%02X", *p);
 
279
      for (length--, p++; length--; p++)
 
280
        log_printf (" %02X", *p);
 
281
    }
 
282
  if (text)
 
283
    log_printf ("\n");
 
284
}
 
285
 
 
286
 
248
287
void
249
288
_gcry_burn_stack (int bytes)
250
289
{