OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.2 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../musl/0001-report-res_query-failures-including-nxdomain-nodata-.patch
  5. # Copyright (C) 2020 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From 19f8642494b7d27b2ceed5c14d4a0b27cb749afe Mon Sep 17 00:00:00 2001
  17. From: Rich Felker <dalias@aerifal.cx>
  18. Date: Mon, 24 Aug 2020 21:56:48 -0400
  19. Subject: [PATCH] report res_query failures, including nxdomain/nodata, via
  20. h_errno
  21. while it's not clearly documented anywhere, this is the historical
  22. behavior which some applications expect. applications which need to
  23. see the response packet in these cases, for example to distinguish
  24. between nonexistence in a secure vs insecure zone, must already use
  25. res_mkquery with res_send in order to be portable, since most if not
  26. all other implementations of res_query don't provide it.
  27. ---
  28. src/network/res_query.c | 16 +++++++++++++++-
  29. 1 file changed, 15 insertions(+), 1 deletion(-)
  30. diff --git a/src/network/res_query.c b/src/network/res_query.c
  31. index 2f4da2e2..506dc231 100644
  32. --- a/src/network/res_query.c
  33. +++ b/src/network/res_query.c
  34. @@ -1,3 +1,4 @@
  35. +#define _BSD_SOURCE
  36. #include <resolv.h>
  37. #include <netdb.h>
  38. @@ -6,7 +7,20 @@ int res_query(const char *name, int class, int type, unsigned char *dest, int le
  39. unsigned char q[280];
  40. int ql = __res_mkquery(0, name, class, type, 0, 0, 0, q, sizeof q);
  41. if (ql < 0) return ql;
  42. - return __res_send(q, ql, dest, len);
  43. + int r = __res_send(q, ql, dest, len);
  44. + if (r<12) {
  45. + h_errno = TRY_AGAIN;
  46. + return -1;
  47. + }
  48. + if ((dest[3] & 15) == 3) {
  49. + h_errno = HOST_NOT_FOUND;
  50. + return -1;
  51. + }
  52. + if ((dest[3] & 15) == 0 && !dest[6] && !dest[7]) {
  53. + h_errno = NO_DATA;
  54. + return -1;
  55. + }
  56. + return r;
  57. }
  58. weak_alias(res_query, res_search);
  59. --
  60. 2.28.0