[2/2] resolv: make res_randomid use random_bits()
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
dj/TryBot-32bit |
success
|
Build for i686
|
Commit Message
It is at least "more random" than 0xffff & __getpid ();
Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
---
resolv/res_randomid.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
Ping..
On Fri, Aug 6, 2021 at 3:18 PM Cristian Rodríguez
<crrodriguez@opensuse.org> wrote:
>
> It is at least "more random" than 0xffff & __getpid ();
>
> Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
> ---
> resolv/res_randomid.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/resolv/res_randomid.c b/resolv/res_randomid.c
> index 546daf4c8b..08a52a111a 100644
> --- a/resolv/res_randomid.c
> +++ b/resolv/res_randomid.c
> @@ -84,9 +84,10 @@
>
> #include <resolv.h>
> #include <unistd.h>
> +#include <random-bits.h>
>
> unsigned int
> res_randomid (void) {
> - return 0xffff & __getpid ();
> + return random_bits();
> }
> libc_hidden_def (__res_randomid)
> --
> 2.32.0
* Cristian Rodríguez:
> It is at least "more random" than 0xffff & __getpid ();
>
> Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
> ---
> resolv/res_randomid.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/resolv/res_randomid.c b/resolv/res_randomid.c
> index 546daf4c8b..08a52a111a 100644
> --- a/resolv/res_randomid.c
> +++ b/resolv/res_randomid.c
> @@ -84,9 +84,10 @@
>
> #include <resolv.h>
> #include <unistd.h>
> +#include <random-bits.h>
>
> unsigned int
> res_randomid (void) {
> - return 0xffff & __getpid ();
> + return random_bits();
> }
> libc_hidden_def (__res_randomid)
The masking with 0xffff needs to remain, and there should be a space
before ().
Thanks,
Florian
On Fri, Aug 20, 2021 at 3:00 AM Florian Weimer <fweimer@redhat.com> wrote:
> > libc_hidden_def (__res_randomid)
>
> The masking with 0xffff needs to remain,
arrgh..damn ! id is an unsigned short..
you are right.
and there should be a space
> before ().
Ok thanks..
@@ -84,9 +84,10 @@
#include <resolv.h>
#include <unistd.h>
+#include <random-bits.h>
unsigned int
res_randomid (void) {
- return 0xffff & __getpid ();
+ return random_bits();
}
libc_hidden_def (__res_randomid)