logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git

1.0.2-Replace-res_randomid_with_arc4random.patch (1850B)


  1. From fb2c3b37d1022d84506ca0815c7c888c4f08e90c Mon Sep 17 00:00:00 2001
  2. From: xentec <xentec@aix0.eu>
  3. Date: Sat, 11 Feb 2017 14:39:24 +0000
  4. Subject: [PATCH 2/3] Replace missing res_randomid() with the more secure
  5. arc4random()
  6. ---
  7. configure.ac | 2 ++
  8. openbsd-compat/openbsd-compat.h | 2 ++
  9. src/res_mkquery.c | 2 +-
  10. src/res_send_async.c | 2 +-
  11. 4 files changed, 6 insertions(+), 2 deletions(-)
  12. diff --git a/configure.ac b/configure.ac
  13. index 10aff04..fa0e896 100644
  14. --- a/configure.ac
  15. +++ b/configure.ac
  16. @@ -264,6 +264,8 @@ AC_ARG_WITH([Werror],
  17. )
  18. #l325
  19. +LIBS="-lcrypto $LIBS"
  20. +
  21. AC_CHECK_HEADERS([ \
  22. crypt.h \
  23. dirent.h \
  24. diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h
  25. index c30591c..9be2e0b 100644
  26. --- a/openbsd-compat/openbsd-compat.h
  27. +++ b/openbsd-compat/openbsd-compat.h
  28. @@ -123,4 +123,6 @@ int res_hnok(const char *);
  29. int clock_gettime(int, struct timespec *);
  30. #endif
  31. +unsigned int arc4random(void);
  32. +
  33. #endif /* _OPENBSD_COMPAT_H */
  34. diff --git a/src/res_mkquery.c b/src/res_mkquery.c
  35. index 27ed21e..cce4029 100644
  36. --- a/src/res_mkquery.c
  37. +++ b/src/res_mkquery.c
  38. @@ -57,7 +57,7 @@ res_mkquery(int op, const char *dname, int class, int type,
  39. ac = asr_use_resolver(NULL);
  40. memset(&h, 0, sizeof h);
  41. - h.id = res_randomid();
  42. + h.id = arc4random();
  43. if (ac->ac_options & RES_RECURSE)
  44. h.flags |= RD_MASK;
  45. h.qdcount = 1;
  46. diff --git a/src/res_send_async.c b/src/res_send_async.c
  47. index a60aa0d..a0f4704 100644
  48. --- a/src/res_send_async.c
  49. +++ b/src/res_send_async.c
  50. @@ -380,7 +380,7 @@ setup_query(struct asr_query *as, const char *name, const char *dom,
  51. as->as.dns.obuflen = 0;
  52. memset(&h, 0, sizeof h);
  53. - h.id = res_randomid();
  54. + h.id = arc4random();
  55. if (as->as_ctx->ac_options & RES_RECURSE)
  56. h.flags |= RD_MASK;
  57. h.qdcount = 1;
  58. --
  59. 2.11.1