- 9DEA2170DE57AC92123D3DAC0FD5930BC5C1A5AC88CA1C2FDA88C8555091A38E5862FD7AC5BCED9393349F66AB970707B27D759FE0041F358A0D205E066ECDE0+ 4E3DCB1355D54A4A2CC9EEBDDFEEAB38E3EDD49F20EF18A7DDCA12CB57497820AE200708B20FA697CEC54E4B65CD8AD3F2487ADD90DEFC420EB33B94AB460304mpi/memory.c(1 . 23)(1 . 26)
3937 /* memory.c - memory allocation
3938 * Copyright (C) 1998, 1999, 2001, 2005 Free Software Foundation, Inc.
3939 * Modified by No Such Labs. (C) 2015. See README.
3940 *
3941 * This file is part of GnuPG.
3942 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
3943 * SHA256(gnupg-1.4.10.tar.gz):
3944 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
3945 * (C) 1994-2005 Free Software Foundation, Inc.
3946 *
3947 * GnuPG is free software; you can redistribute it and/or modify
3948 * This program is free software: you can redistribute it and/or modify
3949 * it under the terms of the GNU General Public License as published by
3950 * the Free Software Foundation; either version 3 of the License, or
3951 * the Free Software Foundation, either version 3 of the License, or
3952 * (at your option) any later version.
3953 *
3954 * GnuPG is distributed in the hope that it will be useful,
3955 * This program is distributed in the hope that it will be useful,
3956 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3957 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3958 * GNU General Public License for more details.
3959 *
3960 * You should have received a copy of the GNU General Public License
3961 * along with this program; if not, see <http://www.gnu.org/licenses/>.
3962 *
3963 *
3964 * We use our own memory allocation functions instead of plain malloc(),
3965 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3966 */
3967
3968 /* We use our own memory allocation functions instead of plain malloc(),
3969 * so that we can provide some special enhancements:
3970 * a) functions to provide memory from a secure memory.
3971 * b) by looking at the requested allocation size we
(27 . 17)(30 . 16)
3973 * d) memory checking if compiled with M_GUARD
3974 */
3975
3976 #include <config.h>
3977 #include <stdio.h>
3978 #include <stdlib.h>
3979 #include <string.h>
3980 #include <stdarg.h>
3981 #include <string.h>
3982
3983 #include "knobs.h"
3984 #include "types.h"
3985 #include "memory.h"
3986 #include "util.h"
3987
3988
3989 #define MAGIC_NOR_BYTE 0x55
3990 #define MAGIC_SEC_BYTE 0xcc
3991 #define MAGIC_END_BYTE 0xaa
(76 . 14)(78 . 10)
3993 #define FNAMEXM(a) m_debug_ ##a
3994 #define FNAMEPRT , const char *info
3995 #define FNAMEARG , info
3996 #ifndef __riscos__
3997
3998 #define store_len(p,n,m) do { add_entry(p,n,m, \
3999 info, __FUNCTION__); } while(0)
4000 #else
4001 #define store_len(p,n,m) do { add_entry(p,n,m, \
4002 info, __func__ ); } while(0)
4003 #endif
4004 #else
4005 #define FNAME(a) m_ ##a
4006 #define FNAMEX(a) x ##a
4007 #define FNAMEXM(a) xm ##a
(337 . 11)(335 . 7)
4009
4010 for( e = memtbl, n = 0; n < memtbl_len; n++, e++ ) {
4011 if( e->inuse ) {
4012 #ifndef __riscos__
4013 check_mem(e->user_p-4-EXTRA_ALIGN, info);
4014 #else
4015 check_mem((const byte *) e->user_p-4-EXTRA_ALIGN, info);
4016 #endif
4017 }
4018 }
4019 }
(411 . 10)(405 . 7)
4021 log_info ("(this may be caused by too many secret keys used "
4022 "simultaneously or due to excessive large key sizes)\n");
4023 }
4024 #if defined(M_GUARD) && defined(__riscos__)
4025 abort();
4026 #endif
4027 exit (2);
4028 exit(2);
4029 }
4030
4031 /****************
(678 . 4)(669 . 3)
4033 out_of_core (nbytes, 1);
4034 return xmalloc_secure_clear (nbytes);
4035 }
4036