patch-mxget_c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. $Id$
  2. --- fetchmail-6.3.9.orig/mxget.c 2007-06-10 10:32:47.000000000 +0200
  3. +++ fetchmail-6.3.9/mxget.c 2009-06-12 22:24:29.000000000 +0200
  4. @@ -56,6 +56,123 @@
  5. /* minimum possible size of MX record in packet */
  6. #define MIN_MX_SIZE 8 /* corresp to "a.com 0" w/ terminating space */
  7. +/* from bind9 package: */
  8. +/*
  9. +Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
  10. +Copyright (C) 1996-2003 Internet Software Consortium.
  11. +
  12. +Permission to use, copy, modify, and distribute this software for any
  13. +purpose with or without fee is hereby granted, provided that the above
  14. +copyright notice and this permission notice appear in all copies.
  15. +
  16. +THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  17. +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  18. +AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  19. +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  20. +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  21. +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  22. +PERFORMANCE OF THIS SOFTWARE.
  23. +
  24. +$Id: COPYRIGHT,v 1.9.18.3 2007/01/08 02:41:59 marka Exp $
  25. +
  26. +Portions Copyright (C) 1996-2001 Nominum, Inc.
  27. +
  28. +Permission to use, copy, modify, and distribute this software for any
  29. +purpose with or without fee is hereby granted, provided that the above
  30. +copyright notice and this permission notice appear in all copies.
  31. +
  32. +THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
  33. +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  34. +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
  35. +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  36. +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  37. +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  38. +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  39. +*/
  40. +#define NS_TYPE_ELT 0x40 /*%< EDNS0 extended label
  41. +type
  42. +*/
  43. +#define NS_CMPRSFLGS 0xc0 /*%< Flag bits indicating name compression. */
  44. +#define DNS_LABELTYPE_BITSTRING 0x41
  45. +static int
  46. +labellen(const u_char *lp)
  47. +{
  48. + int bitlen;
  49. + u_char l = *lp;
  50. +
  51. + if ((l & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
  52. + /* should be avoided by the caller */
  53. + return(-1);
  54. + }
  55. +
  56. + if ((l & NS_CMPRSFLGS) == NS_TYPE_ELT) {
  57. + if (l == DNS_LABELTYPE_BITSTRING) {
  58. + if ((bitlen = *(lp + 1)) == 0)
  59. + bitlen = 256;
  60. + return((bitlen + 7 ) / 8 + 1);
  61. + }
  62. + return(-1); /*%< unknwon ELT */
  63. + }
  64. + return(l);
  65. +}
  66. +/*%
  67. + * Advance *ptrptr to skip over the compressed name it points at.
  68. + *
  69. + * return:
  70. + *\li 0 on success, -1 (with errno set) on failure.
  71. + */
  72. +int
  73. +ns_name_skip(const u_char **ptrptr, const u_char *eom)
  74. +{
  75. + const u_char *cp;
  76. + u_int n;
  77. + int l;
  78. +
  79. + cp = *ptrptr;
  80. + while (cp < eom && (n = *cp++) != 0) {
  81. + /* Check for indirection. */
  82. + switch (n & NS_CMPRSFLGS) {
  83. + case 0: /*%< normal case, n == len */
  84. + cp += n;
  85. + continue;
  86. + case NS_TYPE_ELT: /*%< EDNS0 extended label */
  87. + if ((l = labellen(cp - 1)) < 0) {
  88. +// errno = EMSGSIZE; /*%< XXX */
  89. + return(-1);
  90. + }
  91. + cp += l;
  92. + continue;
  93. + case NS_CMPRSFLGS: /*%< indirection */
  94. + cp++;
  95. + break;
  96. + default: /*%< illegal type */
  97. +// errno = EMSGSIZE;
  98. + return (-1);
  99. + }
  100. + break;
  101. + }
  102. + if (cp > eom) {
  103. +// errno = EMSGSIZE;
  104. + return (-1);
  105. + }
  106. + *ptrptr = cp;
  107. + return (0);
  108. +}
  109. +
  110. +/*%
  111. + * Skip over a compressed domain name. Return the size or -1.
  112. + */
  113. +int
  114. +dn_skipname(const u_char *ptr, const u_char *eom) {
  115. + const u_char *saveptr = ptr;
  116. +
  117. + if (ns_name_skip(&ptr, eom) == -1)
  118. + return (-1);
  119. + return (ptr - saveptr);
  120. +}
  121. +/* End from Bind9 package */
  122. +
  123. +
  124. struct mxentry *getmxrecords(const char *name)
  125. /* get MX records for given host */
  126. {