1
0
wpa_supplicant/wpa_supplicant-getrandom.patch
Ismail Dönmez d8f638566d Accepting request 360174 from home:elvigia:branches:hardware
- Previous update did not include version 2.5 tarball
  or changed the version number in spec, only the changelog
  and removed patches.
- config: set CONFIG_NO_RANDOM_POOL=y, we have a reliable·
 random number generator by using /dev/urandom, no need to
 keep an internal random number pool which draws entropy from 
 /dev/random.
- config: prefer using epoll(7) instead of select(2)
  by setting CONFIG_ELOOP_EPOLL=y
- wpa_supplicant-getrandom.patch: Prefer to use the getrandom(2)
 system call to collect entropy. if it is not present disable
 buffering when reading /dev/urandom, otherwise each os_get_random()
 call will request BUFSIZ of entropy instead of the few needed bytes.

OBS-URL: https://build.opensuse.org/request/show/360174
OBS-URL: https://build.opensuse.org/package/show/hardware/wpa_supplicant?expand=0&rev=60
2016-02-18 15:55:55 +00:00

45 lines
870 B
Diff

--- wpa_supplicant-2.4.orig/src/utils/os_unix.c
+++ wpa_supplicant-2.4/src/utils/os_unix.c
@@ -6,11 +6,15 @@
* See README for more details.
*/
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
#include "includes.h"
#include <time.h>
#include <sys/wait.h>
-
+#include <sys/syscall.h>
+#include <unistd.h>
#ifdef ANDROID
#include <sys/capability.h>
#include <sys/prctl.h>
@@ -223,6 +227,10 @@ void os_daemonize_terminate(const char *
int os_get_random(unsigned char *buf, size_t len)
{
+#ifdef SYS_getrandom
+ int gr = TEMP_FAILURE_RETRY(syscall(SYS_getrandom, buf, len, 0));
+ return (gr != -1 && gr == len) ? 0 : -1;
+#else
FILE *f;
size_t rc;
@@ -232,10 +240,13 @@ int os_get_random(unsigned char *buf, si
return -1;
}
+ setbuf(f, NULL);
+
rc = fread(buf, 1, len, f);
fclose(f);
return rc != len ? -1 : 0;
+#endif
}