[dovecot-cvs] dovecot/src/lib safe-memset.c,NONE,1.1 safe-memset.h,NONE,1.1 Makefile.am,1.20,1.21

cras at procontrol.fi cras at procontrol.fi
Wed Dec 18 12:40:46 EET 2002


Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv7352/lib

Modified Files:
	Makefile.am 
Added Files:
	safe-memset.c safe-memset.h 
Log Message:
Added safe_memset() which guarantees that compiler optimizations don't
optimize it away. Not that we really need to clear the passwords from
memory, but won't hurt much either :)



--- NEW FILE: safe-memset.c ---
/*
   Copyright (c) 2002 Timo Sirainen

    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
    "Software"), to deal in the Software without restriction, including
    without limitation the rights to use, copy, modify, merge, publish,
    distribute, sublicense, and/or sell copies of the Software, and to
    permit persons to whom the Software is furnished to do so, subject to
    the following conditions:

    The above copyright notice and this permission notice shall be
    included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include "lib.h"
#include "safe-memset.h"

void safe_memset(void *data, int c, size_t size)
{
	volatile unsigned char *p = data;

	for (; size > 0; size--)
		*p++ = (unsigned char)c;
}

--- NEW FILE: safe-memset.h ---
#ifndef __SAFE_MEMSET_H
#define __SAFE_MEMSET_H

/* memset() guaranteed not to get optimized away by compiler.
   Should be used instead of memset() when clearing any sensitive data. */
void safe_memset(void *data, int c, size_t size);

#endif

Index: Makefile.am
===================================================================
RCS file: /home/cvs/dovecot/src/lib/Makefile.am,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- Makefile.am	8 Dec 2002 05:23:07 -0000	1.20
+++ Makefile.am	18 Dec 2002 10:40:43 -0000	1.21
@@ -41,6 +41,7 @@
 	randgen.c \
 	restrict-access.c \
 	restrict-process-size.c \
+	safe-memset.c \
 	sendfile-util.c \
 	strfuncs.c \
 	temp-string.c \
@@ -85,6 +86,7 @@
 	randgen.h \
 	restrict-access.h \
 	restrict-process-size.h \
+	safe-memset.h \
 	sendfile-util.h \
 	strfuncs.h \
 	temp-string.h \




More information about the dovecot-cvs mailing list