ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/reslib.c
(Generate patch)

Comparing ircd-hybrid-7.2/src/irc_reslib.c (file contents):
Revision 912 by michael, Wed Nov 7 22:47:44 2007 UTC vs.
Revision 993 by michael, Thu Aug 20 10:44:18 2009 UTC

# Line 124 | Line 124 | static const char digits[] = "0123456789
124   static int labellen(const unsigned char *lp);
125   static int special(int ch);
126   static int printable(int ch);
127 < static int irc_decode_bitstring(const char **cpp, char *dn, const char *eom);
127 > static int irc_decode_bitstring(const unsigned char **cpp, char *dn, const char *eom);
128   static int irc_ns_name_compress(const char *src, unsigned char *dst, size_t dstsiz,
129      const unsigned char **dnptrs, const unsigned char **lastdnptr);
130   static int irc_dn_find(const unsigned char *, const unsigned char *, const unsigned char * const *,
131                         const unsigned char * const *);
132   static int irc_encode_bitsring(const char **, const char *, unsigned char **, unsigned char **,
133 <                               const char *);
133 >                               const unsigned char *);
134   static int irc_ns_name_uncompress(const unsigned char *, const unsigned char *,
135                                    const unsigned char *, char *, size_t);
136   static int irc_ns_name_unpack(const unsigned char *, const unsigned char *,
137                                const unsigned char *, unsigned char *,
138                                size_t);
139 < static int irc_ns_name_ntop(const char *, char *, size_t);
139 > static int irc_ns_name_ntop(const unsigned char *, char *, size_t);
140   static int irc_ns_name_skip(const unsigned char **, const unsigned char *);
141   static int mklower(int ch);
142    
# Line 267 | Line 267 | irc_dn_expand(const unsigned char *msg,
267    if (n > 0 && dst[0] == '.')
268      dst[0] = '\0';
269    return(n);
270 < }
270 > } /*2*/
271  
272   /*
273   * irc_ns_name_uncompress(msg, eom, src, dst, dstsiz)
# Line 286 | Line 286 | irc_ns_name_uncompress(const unsigned ch
286  
287    if ((n = irc_ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1)
288      return(-1);
289 <  if (irc_ns_name_ntop((char*)tmp, dst, dstsiz) == -1)
289 >  if (irc_ns_name_ntop(tmp, dst, dstsiz) == -1)
290      return(-1);
291    return(n);
292 < }
292 > } /*2*/
293 >
294   /*
295   * irc_ns_name_unpack(msg, eom, src, dst, dstsiz)
296   *      Unpack a domain name from a message, source may be compressed.
# Line 369 | Line 370 | irc_ns_name_unpack(const unsigned char *
370          if (len < 0)
371                  len = srcp - src;
372          return (len);
373 < }
373 > } /*2*/
374  
375   /*
376   * irc_ns_name_ntop(src, dst, dstsiz)
# Line 381 | Line 382 | irc_ns_name_unpack(const unsigned char *
382   *      All other domains are returned in non absolute form
383   */
384   static int
385 < irc_ns_name_ntop(const char *src, char *dst, size_t dstsiz)
385 > irc_ns_name_ntop(const unsigned char *src, char *dst, size_t dstsiz)
386   {
387 <        const char *cp;
387 >        const unsigned char *cp;
388          char *dn, *eom;
389          unsigned char c;
390          unsigned int n;
# Line 406 | Line 407 | irc_ns_name_ntop(const char *src, char *
407                          }
408                          *dn++ = '.';
409                  }
410 <                if ((l = labellen((unsigned char*)(cp - 1))) < 0) {
410 >                if ((l = labellen((cp - 1))) < 0) {
411                          errno = EMSGSIZE; /* XXX */
412                          return(-1);
413                  }
# Line 470 | Line 471 | irc_ns_name_ntop(const char *src, char *
471          }
472          *dn++ = '\0';
473          return (dn - dst);
474 < }
474 <
475 < /*
476 < * Pack domain name 'exp_dn' in presentation form into 'comp_dn'.
477 < * Return the size of the compressed name or -1.
478 < * 'length' is the size of the array pointed to by 'comp_dn'.
479 < */
480 < static int
481 < irc_dn_comp(const char *src, unsigned char *dst, int dstsiz,
482 <            unsigned char **dnptrs, unsigned char **lastdnptr)
483 < {
484 <  return(irc_ns_name_compress(src, dst, (size_t)dstsiz,
485 <                              (const unsigned char **)dnptrs,
486 <                              (const unsigned char **)lastdnptr));
487 < }
474 > } /*2*/
475  
476   /*
477   * Skip over a compressed domain name. Return the size or -1.
# Line 496 | Line 483 | irc_dn_skipname(const unsigned char *ptr
483    if (irc_ns_name_skip(&ptr, eom) == -1)
484      return(-1);
485    return(ptr - saveptr);
486 < }
486 > } /*2*/
487  
488   /*
489   * ns_name_skip(ptrptr, eom)
# Line 549 | Line 536 | irc_ns_name_skip(const unsigned char **p
536  
537    *ptrptr = cp;
538    return(0);
539 < }
539 > } /*2*/
540  
541   unsigned int
542   irc_ns_get16(const unsigned char *src)
# Line 608 | Line 595 | special(int ch)
595      default:
596        return(0);
597    }
598 < }
598 > } /*2*/
599  
600   static int
601   labellen(const unsigned char *lp)
# Line 635 | Line 622 | labellen(const unsigned char *lp)
622    }
623  
624    return(l);
625 < }
625 > } /*2*/
626  
627  
628   /*
# Line 649 | Line 636 | static int
636   printable(int ch)
637   {
638    return(ch > 0x20 && ch < 0x7f);
639 < }
639 > } /*2*/
640  
641   static int
642 < irc_decode_bitstring(const char **cpp, char *dn, const char *eom)
642 > irc_decode_bitstring(const unsigned char **cpp, char *dn, const char *eom)
643   {
644 <        const char *cp = *cpp;
644 >        const unsigned char *cp = *cpp;
645          char *beg = dn, tc;
646          int b, blen, plen;
647  
# Line 681 | Line 668 | irc_decode_bitstring(const char **cpp, c
668  
669          *cpp = cp;
670          return(dn - beg);
671 < }
671 > } /*2*/
672  
673   /*
674   * irc_ns_name_pton(src, dst, dstsiz)
# Line 717 | Line 704 | irc_ns_name_pton(const char *src, unsign
704                 cp + 2,
705                 &label,
706                 &bp,
707 <               (const char *)eom))
707 >               eom))
708              != 0) {
709            errno = e;
710            return(-1);
# Line 821 | Line 808 | irc_ns_name_pton(const char *src, unsign
808    }
809  
810    return (0);
811 < }
811 > } /*2*/
812  
813   /*
814   * irc_ns_name_pack(src, dst, dstsiz, dnptrs, lastdnptr)
# Line 930 | Line 917 | cleanup:
917      return (-1);
918    }
919    return(dstp - dst);
920 < }
920 > } /*2*/
921  
922   static int
923   irc_ns_name_compress(const char *src, unsigned char *dst, size_t dstsiz,
# Line 945 | Line 932 | irc_ns_name_compress(const char *src, un
932  
933   static int
934   irc_encode_bitsring(const char **bp, const char *end, unsigned char **labelp,
935 <                    unsigned char **dst, const char *eom)
935 >                    unsigned char **dst, const unsigned char *eom)
936   {
937    int afterslash = 0;
938    const char *cp = *bp;
939 <  char *tp, c;
939 >  unsigned char *tp;
940 >  char c;
941    const char *beg_blen;
942    char *end_blen = NULL;
943    int value = 0, count = 0, tbcount = 0, blen = 0;
# Line 966 | Line 954 | irc_encode_bitsring(const char **bp, con
954    if (!isxdigit((*cp) & 0xff)) /* reject '\[x/BLEN]' */
955      return(EINVAL);
956  
957 <  for (tp = (char*)(dst + 1); cp < end && tp < eom; cp++) {
957 >  for (tp = *dst + 1; cp < end && tp < eom; cp++) {
958      switch((c = *cp)) {
959      case ']': /* end of the bitstring */
960        if (afterslash) {
# Line 1043 | Line 1031 | irc_encode_bitsring(const char **bp, con
1031    **dst = blen;
1032  
1033    *bp = cp;
1034 <  *dst = (unsigned char*)tp;
1034 >  *dst = tp;
1035  
1036    return(0);
1037 < }
1037 > } /*2*/
1038  
1039   /*
1040   * dn_find(domain, msg, dnptrs, lastdnptr)
# Line 1115 | Line 1103 | irc_dn_find(const unsigned char *domain,
1103    }
1104    errno = ENOENT;
1105    return (-1);
1106 < }
1106 > } /*2*/
1107  
1108   /*
1109   *  *  Thinking in noninternationalized USASCII (per the DNS spec),
# Line 1128 | Line 1116 | mklower(int ch)
1116      return(ch + 0x20);
1117  
1118    return(ch);
1119 < }
1119 > } /*2*/
1120  
1121   /* From resolv/mkquery.c */
1122  
# Line 1169 | Line 1157 | irc_res_mkquery(
1157  
1158          if ((buflen -= QFIXEDSZ) < 0)
1159            return (-1);
1160 <        if ((n = irc_dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
1160 >        if ((n = irc_ns_name_compress(dname, cp, buflen, (const unsigned char **)dnptrs,
1161 >                                                         (const unsigned char **)lastdnptr)) < 0)
1162            return (-1);
1163  
1164          cp += n;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)