~ubuntu-branches/ubuntu/oneiric/gnupg2/oneiric-updates

« back to all changes in this revision

Viewing changes to tools/no-libgcrypt.c

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-10-04 10:25:53 UTC
  • mfrom: (5.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081004102553-fv62pp8dsitxli47
Tags: 2.0.9-3.1
* Non-maintainer upload.
* agent/gpg-agent.c: Deinit the threading library before exec'ing
  the command to run in --daemon mode. And because that still doesn't
  restore the sigprocmask, do that manually. Closes: #499569

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* no-libgcrypt.c - Replacement functions for libgcrypt.
2
2
 *      Copyright (C) 2003 Free Software Foundation, Inc.
3
3
 *
4
 
 * This file is part of GnuPG.
5
 
 *
6
 
 * GnuPG is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * GnuPG is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
4
 * This file is free software; as a special exception the author gives
 
5
 * unlimited permission to copy and/or distribute it, with or without
 
6
 * modifications, as long as this notice is preserved.
 
7
 * 
 
8
 * This file is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY, to the extent permitted by law; without even
 
10
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.
19
12
 */
20
13
 
21
14
#include <config.h>
32
25
   ../jnlib/libjnlib.a .  ../common/util.h defines macros to map them
33
26
   to xmalloc etc. */
34
27
static void
35
 
out_of_core (void)
 
28
out_of_memory (void)
36
29
{
37
30
  log_fatal (_("error allocating enough memory: %s\n"), strerror (errno));
38
31
}
45
38
}
46
39
 
47
40
void *
 
41
gcry_malloc_secure (size_t n)
 
42
{
 
43
  return malloc (n);
 
44
}
 
45
 
 
46
void *
48
47
gcry_xmalloc (size_t n)
49
48
{
50
49
  void *p = malloc (n);
51
50
  if (!p)
52
 
    out_of_core ();
 
51
    out_of_memory ();
53
52
  return p;
54
53
}
55
54
 
71
70
{
72
71
  void *p = realloc (a, n);
73
72
  if (!p)
74
 
    out_of_core ();
 
73
    out_of_memory ();
75
74
  return p;
76
75
}
77
76
 
88
87
{
89
88
  void *p = calloc (n, m);
90
89
  if (!p)
91
 
    out_of_core ();
 
90
    out_of_memory ();
92
91
  return p;
93
92
}
94
93
 
98
97
{
99
98
  void *p = malloc (strlen (string)+1);
100
99
  if (!p)
101
 
    out_of_core ();
 
100
    out_of_memory ();
102
101
  strcpy( p, string );
103
102
  return p;
104
103
}
109
108
  if (a)
110
109
    free (a);
111
110
}
 
111
 
 
112
 
 
113
/* We need this dummy because exechelp.c uses gcry_control to
 
114
   terminate the secure memeory.  */
 
115
gcry_error_t 
 
116
gcry_control (enum gcry_ctl_cmds CMD, ...)
 
117
{
 
118
  return 0;
 
119
}
 
120
 
 
121
void 
 
122
gcry_set_outofcore_handler (gcry_handler_no_mem_t h, void *opaque)
 
123
{
 
124
  (void)h;
 
125
  (void)opaque;
 
126
}
 
127
 
 
128
void 
 
129
gcry_set_fatalerror_handler (gcry_handler_error_t fnc, void *opaque)
 
130
{
 
131
  (void)fnc;
 
132
  (void)opaque;
 
133
}
 
134
 
 
135
void 
 
136
gcry_set_log_handler (gcry_handler_log_t f, void *opaque)
 
137
{
 
138
  (void)f;
 
139
  (void)opaque;
 
140
}