Module Name: src
Committed By: riastradh
Date: Wed Aug 28 15:46:23 UTC 2013
Modified Files:
src/common/lib/libc/string: explicit_memset.c
src/include: string.h
src/lib/libc/string: explicit_memset.3
Log Message:
Make explicit_memset match memset's return value.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/string/explicit_memset.c
cvs rdiff -u -r1.46 -r1.47 src/include/string.h
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/string/explicit_memset.3
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/common/lib/libc/string/explicit_memset.c
diff -u src/common/lib/libc/string/explicit_memset.c:1.1 src/common/lib/libc/string/explicit_memset.c:1.2
--- src/common/lib/libc/string/explicit_memset.c:1.1 Mon Jun 24 04:21:19 2013
+++ src/common/lib/libc/string/explicit_memset.c Wed Aug 28 15:46:23 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: explicit_memset.c,v 1.1 2013/06/24 04:21:19 riastradh Exp $ */
+/* $NetBSD: explicit_memset.c,v 1.2 2013/08/28 15:46:23 riastradh Exp $ */
#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <string.h>
@@ -14,9 +14,9 @@
*/
void *(* volatile explicit_memset_impl)(void *, int, size_t) = memset;
-void
+void *
explicit_memset(void *b, int c, size_t len)
{
- (*explicit_memset_impl)(b, c, len);
+ return (*explicit_memset_impl)(b, c, len);
}
Index: src/include/string.h
diff -u src/include/string.h:1.46 src/include/string.h:1.47
--- src/include/string.h:1.46 Tue Aug 27 18:29:28 2013
+++ src/include/string.h Wed Aug 28 15:46:23 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: string.h,v 1.46 2013/08/27 18:29:28 joerg Exp $ */
+/* $NetBSD: string.h,v 1.47 2013/08/28 15:46:23 riastradh Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -103,7 +103,7 @@ char *strsep(char **, const char *);
char *stresep(char **, const char *, int);
char *strndup(const char *, size_t);
void *memrchr(const void *, int, size_t);
-void __explicit_memset(void *, int, size_t);
+void *__explicit_memset(void *, int, size_t);
int __consttime_memequal(const void *, const void *, size_t);
__END_DECLS
#endif
Index: src/lib/libc/string/explicit_memset.3
diff -u src/lib/libc/string/explicit_memset.3:1.1 src/lib/libc/string/explicit_memset.3:1.2
--- src/lib/libc/string/explicit_memset.3:1.1 Mon Jun 24 04:21:20 2013
+++ src/lib/libc/string/explicit_memset.3 Wed Aug 28 15:46:23 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: explicit_memset.3,v 1.1 2013/06/24 04:21:20 riastradh Exp $
+.\" $NetBSD: explicit_memset.3,v 1.2 2013/08/28 15:46:23 riastradh Exp $
.\"
.\" Copyright (c) 2013 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd June 23, 2013
+.Dd August 28, 2013
.Dt EXPLICIT_MEMSET 3
.Os
.Sh NAME
@@ -37,7 +37,7 @@
.Lb libc
.Sh SYNOPSIS
.In string.h
-.Ft void
+.Ft void *
.Fn explicit_memset "void *b" "int c" "size_t len"
.Sh DESCRIPTION
The
@@ -51,6 +51,11 @@ bytes of value
It is guaranteed not to be optimized away by the compiler even if
.Fa b
is no longer used and is about to be freed or go out of scope.
+.Sh RETURN VALUES
+The
+.Fn explicit_memset
+function returns the original value of
+.Fa b .
.Sh EXAMPLES
Create a buffer on the stack for a secret key, use it, and then zero it
in memory before throwing it away.