MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / dns_txt_parser

Function dns_txt_parser

resolve.c:983–1013  ·  view source on GitHub ↗

! \brief Parses a TXT record into a txt_rdata structure * \note RFC1035: * - is a single length octet followed by that number of characters. * - TXT-DATA One or more s. * * We only take the first string here. */

Source from the content-addressed store, hash-verified

981 * We only take the first string here.
982 */
983struct txt_rdata* dns_txt_parser( unsigned char* msg, unsigned char* end,
984 unsigned char* rdata)
985{
986 struct txt_rdata* txt;
987 unsigned int len;
988
989 txt=0;
990 txt=(struct txt_rdata*)local_malloc(sizeof(struct txt_rdata));
991 if(txt==0){
992 LM_ERR("out of pkg memory\n");
993 goto error;
994 }
995
996 len = *rdata;
997 if (rdata + 1 + len >= end)
998 goto error; /* something fishy in the record */
999
1000#if 0
1001 /* Comparison is always false because len <= 255. */
1002 if (len >= sizeof(txt->txt))
1003 goto error; /* not enough space? */
1004#endif
1005 memcpy(txt->txt, rdata+1, len);
1006 txt->txt[len] = 0; /* 0-terminate string */
1007 return txt;
1008
1009error:
1010 if (txt)
1011 local_free(txt);
1012 return 0;
1013}
1014
1015
1016/*! \brief parses a EBL record into a ebl_rdata structure

Callers 1

get_recordFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected