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.

78 lines
2.7 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../musl/0001-handle-non-matching-address-family-entries-in-hosts-.patch
  5. # Copyright (C) 2016 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 6d70c08a2c37745df637b231711f6dec79dbc6e1 Mon Sep 17 00:00:00 2001
  17. From: Rich Felker <dalias@aerifal.cx>
  18. Date: Wed, 2 Mar 2016 00:34:51 -0500
  19. Subject: [PATCH] handle non-matching address family entries in hosts file
  20. name_from_hosts failed to account for the possibility of an address
  21. family error from name_from_numeric, wrongly counting such a return as
  22. success and using the uninitialized address data as part of the
  23. results passed up to the caller.
  24. non-matching address family entries cannot simply be ignored or
  25. results would be inconsistent with respect to whether AF_UNSPEC or a
  26. specific address family is queried. instead, record that a
  27. non-matching entry was seen, and fail the lookup with EAI_NONAME of no
  28. matching-family entries are found.
  29. ---
  30. src/network/lookup_name.c | 14 +++++++++++---
  31. 1 file changed, 11 insertions(+), 3 deletions(-)
  32. diff --git a/src/network/lookup_name.c b/src/network/lookup_name.c
  33. index a26ad53..86f90ac 100644
  34. --- a/src/network/lookup_name.c
  35. +++ b/src/network/lookup_name.c
  36. @@ -49,7 +49,7 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati
  37. {
  38. char line[512];
  39. size_t l = strlen(name);
  40. - int cnt = 0;
  41. + int cnt = 0, badfam = 0;
  42. unsigned char _buf[1032];
  43. FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf);
  44. if (!f) switch (errno) {
  45. @@ -71,8 +71,16 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati
  46. /* Isolate IP address to parse */
  47. for (p=line; *p && !isspace(*p); p++);
  48. *p++ = 0;
  49. - if (name_from_numeric(buf+cnt, line, family))
  50. + switch (name_from_numeric(buf+cnt, line, family)) {
  51. + case 1:
  52. cnt++;
  53. + break;
  54. + case 0:
  55. + continue;
  56. + default:
  57. + badfam = EAI_NONAME;
  58. + continue;
  59. + }
  60. /* Extract first name as canonical name */
  61. for (; *p && isspace(*p); p++);
  62. @@ -81,7 +89,7 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati
  63. if (is_valid_hostname(p)) memcpy(canon, p, z-p+1);
  64. }
  65. __fclose_ca(f);
  66. - return cnt;
  67. + return cnt ? cnt : badfam;
  68. }
  69. struct dpc_ctx {
  70. --
  71. 2.7.2