Blame lib/minitasn1/gstr.h

Packit 549fdc
/*
Packit 549fdc
 * Copyright (C) 2002-2014 Free Software Foundation, Inc.
Packit 549fdc
 *
Packit 549fdc
 * This file is part of LIBTASN1.
Packit 549fdc
 *
Packit 549fdc
 * The LIBTASN1 library is free software; you can redistribute it
Packit 549fdc
 * and/or modify it under the terms of the GNU Lesser General Public
Packit 549fdc
 * License as published by the Free Software Foundation; either
Packit 549fdc
 * version 2.1 of the License, or (at your option) any later version.
Packit 549fdc
 *
Packit 549fdc
 * This library is distributed in the hope that it will be useful, but
Packit 549fdc
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 549fdc
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 549fdc
 * Lesser General Public License for more details.
Packit 549fdc
 *
Packit 549fdc
 * You should have received a copy of the GNU Lesser General Public
Packit 549fdc
 * License along with this library; if not, write to the Free Software
Packit 549fdc
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit 549fdc
 * 02110-1301, USA
Packit 549fdc
 */
Packit 549fdc
Packit 549fdc
unsigned int _asn1_str_cpy (char *dest, size_t dest_tot_size,
Packit 549fdc
			    const char *src);
Packit 549fdc
void _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src);
Packit 549fdc
Packit 549fdc
#define Estrcpy(x,y) _asn1_str_cpy(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
Packit 549fdc
#define Estrcat(x,y) _asn1_str_cat(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
Packit 549fdc
Packit 549fdc
inline static
Packit 549fdc
void safe_memset(void *data, int c, size_t size)
Packit 549fdc
{
Packit 549fdc
	volatile unsigned volatile_zero = 0;
Packit 549fdc
	volatile char *vdata = (volatile char*)data;
Packit 549fdc
Packit 549fdc
	/* This is based on a nice trick for safe memset,
Packit 549fdc
	 * sent by David Jacobson in the openssl-dev mailing list.
Packit 549fdc
	 */
Packit 549fdc
Packit 549fdc
	if (size > 0) do {
Packit 549fdc
		memset(data, c, size);
Packit 549fdc
	} while(vdata[volatile_zero] != c);
Packit 549fdc
}