2 /* Copyright 1998 by the Massachusetts Institute of Technology.
4 * Permission to use, copy, modify, and distribute this
5 * software and its documentation for any purpose and without
6 * fee is hereby granted, provided that the above copyright
7 * notice appear in all copies and that both that copyright
8 * notice and this permission notice appear in supporting
9 * documentation, and that the name of M.I.T. not be used in
10 * advertising or publicity pertaining to distribution of the
11 * software without specific, written prior permission.
12 * M.I.T. makes no representations about the suitability of
13 * this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
17 #include "ares_setup.h"
19 #ifdef HAVE_NETINET_IN_H
20 # include <netinet/in.h>
22 #ifdef HAVE_ARPA_NAMESER_H
23 # include <arpa/nameser.h>
29 #include "ares_private.h" /* for the memdebug */
31 /* Simply decodes a length-encoded character string. The first byte of the
32 * input is the length of the string to be returned and the bytes thereafter
33 * are the characters of the string. The returned result will be NULL
36 int ares_expand_string(const unsigned char *encoded,
37 const unsigned char *abuf,
48 if (encoded == abuf+alen)
52 if (encoded+elen.sig+1 > abuf+alen)
57 *s = ares_malloc(elen.uns+1);
61 strncpy((char *)q, (char *)encoded, elen.uns);
66 *enclen = (long)(elen.sig+1);