From: "Daniel Cegiełka" <daniel.cegielka@gmail.com>
To: musl@lists.openwall.com
Subject: Re: thoughts on reallocarray, explicit_bzero?
Date: Thu, 29 Jan 2015 11:54:48 +0100 [thread overview]
Message-ID: <CAPLrYERBcr04-c4baHeGUmJg2TuUpXVp8BUeV+pw=swd9n=o-A@mail.gmail.com> (raw)
In-Reply-To: <20150129100431.GJ32318@port70.net>
2015-01-29 11:04 GMT+01:00 Szabolcs Nagy <nsz@port70.net>:
> * Daniel Cegie??ka <daniel.cegielka@gmail.com> [2015-01-29 10:30:40 +0100]:
>> yet another secure_memzero(). A better solution would be to promote a
>> single standard (eg. memset_s()) and the expectation that the compiler
>> will respect it.
>>
>
> i think you don't know the semantics of memset_s
> (it uses nonsense types, has superflous arguments, handles
> constraint violations through global state etc)
btw. memset_s() is an attempt to solve the same problem. However, this
version will not work with LTO:
ftp://ftp.netbsd.org/pub/NetBSD/misc/apb/memset_s.20120224.diff
#include <sys/cdefs.h>
__RCSID("$NetBSD$");
#define __STDC_WANT_LIB_EXT1__ 1
#include <errno.h>
#include <stdint.h>
#include <string.h>
/*
* __memset_vp is a volatile pointer to a function.
* It is initialised to point to memset, and should never be changed.
*/
static void * (* const volatile __memset_vp)(void *, int, size_t)
= (memset);
#undef memset_s /* in case it was defined as a macro */
errno_t
memset_s(void *s, rsize_t smax, int c, rsize_t n)
{
errno_t err = 0;
if (s == NULL) {
err = EINVAL;
goto out;
}
if (smax > RSIZE_MAX) {
err = E2BIG;
goto out;
}
if (n > RSIZE_MAX) {
err = E2BIG;
n = smax;
}
if (n > smax) {
err = EOVERFLOW;
n = smax;
}
/* Calling through a volatile pointer should never be optimised away. */
(*__memset_vp)(s, c, n);
out:
if (err == 0)
return 0;
else {
errno = err;
/* XXX call runtime-constraint handler */
return err;
}
}
next prev parent reply other threads:[~2015-01-29 10:54 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-19 15:31 Isaac Dunham
2014-05-19 15:43 ` Rich Felker
2014-05-19 16:19 ` Daniel Cegiełka
2014-05-20 6:19 ` Rich Felker
2014-05-20 15:50 ` Daniel Cegiełka
2014-05-19 15:44 ` Daniel Cegiełka
2014-05-19 16:16 ` Rich Felker
2014-05-19 16:30 ` Daniel Cegiełka
2014-05-19 16:32 ` Szabolcs Nagy
2015-01-28 22:01 ` Daniel Cegiełka
2015-01-28 22:34 ` Daniel Cegiełka
2015-01-28 22:38 ` Nathan McSween
2015-01-28 22:54 ` Daniel Cegiełka
2015-01-28 23:02 ` Josiah Worcester
2015-01-29 2:19 ` Rich Felker
2015-01-29 4:03 ` Brent Cook
2015-01-29 4:15 ` Rich Felker
2015-01-29 9:30 ` Daniel Cegiełka
2015-01-29 10:04 ` Szabolcs Nagy
2015-01-29 10:31 ` Daniel Cegiełka
2015-01-29 10:54 ` Daniel Cegiełka [this message]
2014-05-19 16:25 ` Szabolcs Nagy
2014-05-19 16:45 ` Daniel Cegiełka
2014-05-19 16:58 ` Rich Felker
2014-05-19 16:55 ` Rich Felker
2014-05-19 18:12 ` Szabolcs Nagy
2014-05-19 22:08 ` Andy Lutomirski
2014-05-20 0:41 ` Szabolcs Nagy
2014-06-11 9:59 ` Thorsten Glaser
2014-06-11 12:59 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPLrYERBcr04-c4baHeGUmJg2TuUpXVp8BUeV+pw=swd9n=o-A@mail.gmail.com' \
--to=daniel.cegielka@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).