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.

103 lines
3.3 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../uclibc/add-dns-skipname.patch
  5. # Copyright (C) 2004 - 2006 The T2 SDE 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. # --- T2-COPYRIGHT-NOTE-END ---
  16. --- uClibc-0.9.27/libc/inet/resolv.c.orig 2005-02-01 11:16:03.000000000 -0800
  17. +++ uClibc-0.9.27/libc/inet/resolv.c 2005-02-01 11:27:30.000000000 -0800
  18. @@ -2543,4 +2543,85 @@
  19. return (len);
  20. }
  21. libc_hidden_def(ns_name_unpack)
  22. +
  23. +#define NS_TYPE_ELT 0x40 /* EDNS0 extended label type */
  24. +#define DNS_LABELTYPE_BITSTRING 0x41
  25. +
  26. +int
  27. +__labellen(const u_char *lp)
  28. +{
  29. + int bitlen;
  30. + u_char l = *lp;
  31. +
  32. + if ((l & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
  33. + /* should be avoided by the caller */
  34. + return(-1);
  35. + }
  36. +
  37. + if ((l & NS_CMPRSFLGS) == NS_TYPE_ELT) {
  38. + if (l == DNS_LABELTYPE_BITSTRING) {
  39. + if ((bitlen = *(lp + 1)) == 0)
  40. + bitlen = 256;
  41. + return((bitlen + 7 ) / 8 + 1);
  42. + }
  43. + return(-1); /* unknwon ELT */
  44. + }
  45. + return(l);
  46. +}
  47. +
  48. +/*
  49. + * ns_name_skip(ptrptr, eom)
  50. + * Advance *ptrptr to skip over the compressed name it points at.
  51. + * return:
  52. + * 0 on success, -1 (with errno set) on failure.
  53. + */
  54. +int
  55. +__ns_name_skip(const u_char **ptrptr, const u_char *eom)
  56. +{
  57. + const u_char *cp;
  58. + u_int n;
  59. + int l;
  60. +
  61. + cp = *ptrptr;
  62. + while (cp < eom && (n = *cp++) != 0) {
  63. + /* Check for indirection. */
  64. + switch (n & NS_CMPRSFLGS) {
  65. + case 0: /* normal case, n == len */
  66. + cp += n;
  67. + continue;
  68. + case NS_TYPE_ELT: /* EDNS0 extended label */
  69. + if ((l = __labellen(cp - 1)) < 0) {
  70. + __set_errno(EMSGSIZE);
  71. + return(-1);
  72. + }
  73. + cp += l;
  74. + continue;
  75. + case NS_CMPRSFLGS: /* indirection */
  76. + cp++;
  77. + break;
  78. + default: /* illegal type */
  79. + __set_errno(EMSGSIZE);
  80. + return (-1);
  81. + }
  82. + break;
  83. + }
  84. + if (cp > eom) {
  85. + __set_errno(EMSGSIZE);
  86. + return (-1);
  87. + }
  88. + *ptrptr = cp;
  89. + return (0);
  90. +}
  91. +
  92. +/*
  93. + * Skip over a compressed domain name. Return the size or -1.
  94. + */
  95. +int
  96. +__dn_skipname(const u_char *ptr, const u_char *eom) {
  97. + const u_char *saveptr = ptr;
  98. +
  99. + if (__ns_name_skip(&ptr, eom) == -1)
  100. + return (-1);
  101. + return (ptr - saveptr);
  102. +}
  103. #endif /* L_ns_name */