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.

104 lines
3.3 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../uclibc/add-dns-skipname.patch
  5. # Copyright (C) 2007 The OpenSDE Project
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This patch file is dual-licensed. It is available under the license the
  11. # patched project is licensed under, as long as it is an OpenSource license
  12. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  13. # of the GNU General Public License as published by the Free Software
  14. # Foundation; either version 2 of the License, or (at your option) any later
  15. # version.
  16. # --- SDE-COPYRIGHT-NOTE-END ---
  17. --- uClibc-0.9.27/libc/inet/resolv.c.orig 2005-02-01 11:16:03.000000000 -0800
  18. +++ uClibc-0.9.27/libc/inet/resolv.c 2005-02-01 11:27:30.000000000 -0800
  19. @@ -2543,4 +2543,85 @@
  20. len = srcp - src;
  21. return (len);
  22. }
  23. +
  24. +#define NS_TYPE_ELT 0x40 /* EDNS0 extended label type */
  25. +#define DNS_LABELTYPE_BITSTRING 0x41
  26. +
  27. +int
  28. +__labellen(const u_char *lp)
  29. +{
  30. + int bitlen;
  31. + u_char l = *lp;
  32. +
  33. + if ((l & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
  34. + /* should be avoided by the caller */
  35. + return(-1);
  36. + }
  37. +
  38. + if ((l & NS_CMPRSFLGS) == NS_TYPE_ELT) {
  39. + if (l == DNS_LABELTYPE_BITSTRING) {
  40. + if ((bitlen = *(lp + 1)) == 0)
  41. + bitlen = 256;
  42. + return((bitlen + 7 ) / 8 + 1);
  43. + }
  44. + return(-1); /* unknwon ELT */
  45. + }
  46. + return(l);
  47. +}
  48. +
  49. +/*
  50. + * ns_name_skip(ptrptr, eom)
  51. + * Advance *ptrptr to skip over the compressed name it points at.
  52. + * return:
  53. + * 0 on success, -1 (with errno set) on failure.
  54. + */
  55. +int
  56. +__ns_name_skip(const u_char **ptrptr, const u_char *eom)
  57. +{
  58. + const u_char *cp;
  59. + u_int n;
  60. + int l;
  61. +
  62. + cp = *ptrptr;
  63. + while (cp < eom && (n = *cp++) != 0) {
  64. + /* Check for indirection. */
  65. + switch (n & NS_CMPRSFLGS) {
  66. + case 0: /* normal case, n == len */
  67. + cp += n;
  68. + continue;
  69. + case NS_TYPE_ELT: /* EDNS0 extended label */
  70. + if ((l = __labellen(cp - 1)) < 0) {
  71. + __set_errno(EMSGSIZE);
  72. + return(-1);
  73. + }
  74. + cp += l;
  75. + continue;
  76. + case NS_CMPRSFLGS: /* indirection */
  77. + cp++;
  78. + break;
  79. + default: /* illegal type */
  80. + __set_errno(EMSGSIZE);
  81. + return (-1);
  82. + }
  83. + break;
  84. + }
  85. + if (cp > eom) {
  86. + __set_errno(EMSGSIZE);
  87. + return (-1);
  88. + }
  89. + *ptrptr = cp;
  90. + return (0);
  91. +}
  92. +
  93. +/*
  94. + * Skip over a compressed domain name. Return the size or -1.
  95. + */
  96. +int
  97. +__dn_skipname(const u_char *ptr, const u_char *eom) {
  98. + const u_char *saveptr = ptr;
  99. +
  100. + if (__ns_name_skip(&ptr, eom) == -1)
  101. + return (-1);
  102. + return (ptr - saveptr);
  103. +}
  104. #endif /* L_ns_name */