"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "compat/getentropy_linux.c" between
openbgpd-6.7p0.tar.gz and openbgpd-6.8p0.tar.gz

About: OpenBGPD is a Border Gateway Protocol (BGP) daemon which manages the network routing tables. Its main purpose is to exchange information concerning "network reachability" with other BGP systems.

getentropy_linux.c  (openbgpd-6.7p0):getentropy_linux.c  (openbgpd-6.8p0)
/* $OpenBSD: getentropy_linux.c,v 1.46 2018/11/20 08:04:28 deraadt Exp $ * / /* $OpenBSD: getentropy_linux.c,v 1.47 2020/05/17 14:44:20 deraadt Exp $ * /
/* /*
* Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
* Copyright (c) 2014 Bob Beck <beck@obtuse.com> * Copyright (c) 2014 Bob Beck <beck@obtuse.com>
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies. * copyright notice and this permission notice appear in all copies.
* *
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
skipping to change at line 60 skipping to change at line 60
#include <sha2.h> #include <sha2.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/random.h> #include <linux/random.h>
#ifdef HAVE_GETAUXVAL #ifdef HAVE_GETAUXVAL
#include <sys/auxv.h> #include <sys/auxv.h>
#endif #endif
#include <sys/vfs.h> #include <sys/vfs.h>
#define REPEAT 5 #define REPEAT 5
#define min(a, b) (((a) < (b)) ? (a) : (b)) #define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
#define HX(a, b) \ #define HX(a, b) \
do { \ do { \
if ((a)) \ if ((a)) \
HD(errno); \ HD(errno); \
else \ else \
HD(b); \ HD(b); \
} while (0) } while (0)
#define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l)))
skipping to change at line 263 skipping to change at line 263
#ifdef SYS__sysctl #ifdef SYS__sysctl
static int static int
getentropy_sysctl(void *buf, size_t len) getentropy_sysctl(void *buf, size_t len)
{ {
static int mib[] = { CTL_KERN, KERN_RANDOM, RANDOM_UUID }; static int mib[] = { CTL_KERN, KERN_RANDOM, RANDOM_UUID };
size_t i; size_t i;
int save_errno = errno; int save_errno = errno;
for (i = 0; i < len; ) { for (i = 0; i < len; ) {
size_t chunk = min(len - i, 16); size_t chunk = MINIMUM(len - i, 16);
/* SYS__sysctl because some systems already removed sysctl() */ /* SYS__sysctl because some systems already removed sysctl() */
struct __sysctl_args args = { struct __sysctl_args args = {
.name = mib, .name = mib,
.nlen = 3, .nlen = 3,
.oldval = (char *)buf + i, .oldval = (char *)buf + i,
.oldlenp = &chunk, .oldlenp = &chunk,
}; };
if (syscall(SYS__sysctl, &args) != 0) if (syscall(SYS__sysctl, &args) != 0)
goto sysctlfailed; goto sysctlfailed;
skipping to change at line 518 skipping to change at line 518
HR(p, pgs); HR(p, pgs);
#endif #endif
#ifdef AT_BASE #ifdef AT_BASE
p = (char *) getauxval(AT_BASE); p = (char *) getauxval(AT_BASE);
if (p) if (p)
HD(p); HD(p);
#endif #endif
#endif #endif
SHA512_Final(results, &ctx); SHA512_Final(results, &ctx);
memcpy((char *)buf + i, results, min(sizeof(results), len - i)); memcpy((char *)buf + i, results, MINIMUM(sizeof(results), len - i
i += min(sizeof(results), len - i); ));
i += MINIMUM(sizeof(results), len - i);
} }
explicit_bzero(&ctx, sizeof ctx); explicit_bzero(&ctx, sizeof ctx);
explicit_bzero(results, sizeof results); explicit_bzero(results, sizeof results);
errno = save_errno; errno = save_errno;
return (0); /* satisfied */ return (0); /* satisfied */
} }
 End of changes. 4 change blocks. 
5 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)