diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2021-05-27 18:18:42 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2021-05-27 18:18:42 +0000 |
commit | 47aa03d596a4dec2363ffacc4871574446d70811 (patch) | |
tree | 527e35c19a08ed23ce104b824b842e0b2514d314 /regress | |
parent | ec96000e8b4cafb078e1f926de1c414a45b878f9 (diff) |
Check that libexpat uses arc4random_buf as entropy source.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/lib/libexpat/Makefile | 4 | ||||
-rw-r--r-- | regress/lib/libexpat/entropy/Makefile | 11 | ||||
-rw-r--r-- | regress/lib/libexpat/entropy/entropy.c | 40 |
3 files changed, 53 insertions, 2 deletions
diff --git a/regress/lib/libexpat/Makefile b/regress/lib/libexpat/Makefile index deb357a5322..63c2eaefb98 100644 --- a/regress/lib/libexpat/Makefile +++ b/regress/lib/libexpat/Makefile @@ -1,5 +1,5 @@ -# $OpenBSD: Makefile,v 1.1 2017/06/30 14:56:08 bluhm Exp $ +# $OpenBSD: Makefile,v 1.2 2021/05/27 18:18:41 bluhm Exp $ -SUBDIR= runtests runtestspp benchmark +SUBDIR= runtests runtestspp benchmark entropy .include <bsd.subdir.mk> diff --git a/regress/lib/libexpat/entropy/Makefile b/regress/lib/libexpat/entropy/Makefile new file mode 100644 index 00000000000..522db333040 --- /dev/null +++ b/regress/lib/libexpat/entropy/Makefile @@ -0,0 +1,11 @@ +# $OpenBSD: Makefile,v 1.1 2021/05/27 18:18:41 bluhm Exp $ +# check that libexpat uses arc4random_buf as entropy source + +CLEANFILES= stderr stdout + +run-regress-entropy: entropy + ./entropy 2>stderr >stdout + cat stderr stdout + grep -q arc4random_buf stderr + +.include <bsd.regress.mk> diff --git a/regress/lib/libexpat/entropy/entropy.c b/regress/lib/libexpat/entropy/entropy.c new file mode 100644 index 00000000000..a227110b75c --- /dev/null +++ b/regress/lib/libexpat/entropy/entropy.c @@ -0,0 +1,40 @@ +/* $OpenBSD: entropy.c,v 1.1 2021/05/27 18:18:41 bluhm Exp $ */ + +/* + * Copyright (c) 2021 Alexander Bluhm <bluhm@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <err.h> +#include <expat.h> +#include <string.h> + +int +main(int argc, char *argv[]) +{ + XML_Parser p; + enum XML_Status s; + + if (setenv("EXPAT_ENTROPY_DEBUG", "1", 1) != 0) + err(1, "setenv EXPAT_ENTROPY_DEBUG"); + + p = XML_ParserCreate(NULL); + if (p == NULL) + errx(1, "XML_ParserCreate"); + s = XML_Parse(p, "", 0, 0); + if (s != XML_STATUS_OK) + errx(1, "XML_Parse: %d", s); + + return 0; +} |