Browse Source

As done everywhere else, use a local version of MINIMUM() and avoid

conflict against a potential define min() from some other scope.
master
deraadt 4 years ago
parent
commit
5e398339ba
5 changed files with 21 additions and 21 deletions
  1. +4
    -4
      src/lib/libcrypto/arc4random/getentropy_aix.c
  2. +4
    -4
      src/lib/libcrypto/arc4random/getentropy_hpux.c
  3. +5
    -5
      src/lib/libcrypto/arc4random/getentropy_linux.c
  4. +4
    -4
      src/lib/libcrypto/arc4random/getentropy_osx.c
  5. +4
    -4
      src/lib/libcrypto/arc4random/getentropy_solaris.c

+ 4
- 4
src/lib/libcrypto/arc4random/getentropy_aix.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: getentropy_aix.c,v 1.6 2018/11/20 08:04:28 deraadt Exp $ */
/* $OpenBSD: getentropy_aix.c,v 1.7 2020/05/17 14:44:20 deraadt Exp $ */
/*
* Copyright (c) 2015 Michael Felt <aixtools@gmail.com>
@ -44,7 +44,7 @@
#include <libperfstat.h>
#define REPEAT 5
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
#define HX(a, b) \
do { \
@ -392,8 +392,8 @@ getentropy_fallback(void *buf, size_t len)
HD(cnt);
}
SHA512_Final(results, &ctx);
memcpy((char *)buf + i, results, min(sizeof(results), len - i));
i += min(sizeof(results), len - i);
memcpy((char *)buf + i, results, MINIMUM(sizeof(results), len - i));
i += MINIMUM(sizeof(results), len - i);
}
explicit_bzero(&ctx, sizeof ctx);
explicit_bzero(results, sizeof results);


+ 4
- 4
src/lib/libcrypto/arc4random/getentropy_hpux.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: getentropy_hpux.c,v 1.6 2018/11/20 08:04:28 deraadt Exp $ */
/* $OpenBSD: getentropy_hpux.c,v 1.7 2020/05/17 14:44:20 deraadt Exp $ */
/*
* Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
@ -48,7 +48,7 @@
#include <sys/pstat.h>
#define REPEAT 5
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
#define HX(a, b) \
do { \
@ -386,8 +386,8 @@ getentropy_fallback(void *buf, size_t len)
HD(cnt);
}
SHA512_Final(results, &ctx);
memcpy((char *)buf + i, results, min(sizeof(results), len - i));
i += min(sizeof(results), len - i);
memcpy((char *)buf + i, results, MINIMUM(sizeof(results), len - i));
i += MINIMUM(sizeof(results), len - i);
}
explicit_bzero(&ctx, sizeof ctx);
explicit_bzero(results, sizeof results);


+ 5
- 5
src/lib/libcrypto/arc4random/getentropy_linux.c View File

@ -1,4 +1,4 @@
/* $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>
@ -57,7 +57,7 @@
#include <sys/vfs.h>
#define REPEAT 5
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
#define HX(a, b) \
do { \
@ -260,7 +260,7 @@ getentropy_sysctl(void *buf, size_t len)
int save_errno = errno;
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() */
struct __sysctl_args args = {
@ -515,8 +515,8 @@ getentropy_fallback(void *buf, size_t len)
#endif
SHA512_Final(results, &ctx);
memcpy((char *)buf + i, results, min(sizeof(results), len - i));
i += min(sizeof(results), len - i);
memcpy((char *)buf + i, results, MINIMUM(sizeof(results), len - i));
i += MINIMUM(sizeof(results), len - i);
}
explicit_bzero(&ctx, sizeof ctx);
explicit_bzero(results, sizeof results);


+ 4
- 4
src/lib/libcrypto/arc4random/getentropy_osx.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: getentropy_osx.c,v 1.12 2018/11/20 08:04:28 deraadt Exp $ */
/* $OpenBSD: getentropy_osx.c,v 1.13 2020/05/17 14:44:20 deraadt Exp $ */
/*
* Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
@ -66,7 +66,7 @@
#define SHA512_DIGEST_LENGTH CC_SHA512_DIGEST_LENGTH
#define REPEAT 5
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
#define HX(a, b) \
do { \
@ -407,8 +407,8 @@ getentropy_fallback(void *buf, size_t len)
}
SHA512_Final(results, &ctx);
memcpy((char *)buf + i, results, min(sizeof(results), len - i));
i += min(sizeof(results), len - i);
memcpy((char *)buf + i, results, MINIMUM(sizeof(results), len - i));
i += MINIMUM(sizeof(results), len - i);
}
explicit_bzero(&ctx, sizeof ctx);
explicit_bzero(results, sizeof results);


+ 4
- 4
src/lib/libcrypto/arc4random/getentropy_solaris.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: getentropy_solaris.c,v 1.13 2018/11/20 08:04:28 deraadt Exp $ */
/* $OpenBSD: getentropy_solaris.c,v 1.14 2020/05/17 14:44:20 deraadt Exp $ */
/*
* Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
@ -52,7 +52,7 @@
#include <sys/loadavg.h>
#define REPEAT 5
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
#define HX(a, b) \
do { \
@ -412,8 +412,8 @@ getentropy_fallback(void *buf, size_t len)
HD(cnt);
}
SHA512_Final(results, &ctx);
memcpy((char *)buf + i, results, min(sizeof(results), len - i));
i += min(sizeof(results), len - i);
memcpy((char *)buf + i, results, MINIMUM(sizeof(results), len - i));
i += MINIMUM(sizeof(results), len - i);
}
explicit_bzero(&ctx, sizeof ctx);
explicit_bzero(results, sizeof results);


Loading…
Cancel
Save