[asterisk-commits] trunk - r7797 in /trunk: ./ channels/ include/asterisk/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Jan 4 15:54:10 CST 2006


Author: kpfleming
Date: Wed Jan  4 15:54:09 2006
New Revision: 7797

URL: http://svn.digium.com/view/asterisk?rev=7797&view=rev
Log:
add memory-pool based string field management for structures
convert chan_sip sip_pvt and sip_registry structures to use string fields
add 'const' qualifiers to a few API calls that don't modify their input strings
add an asprintf() wrapper to astmm

Added:
    trunk/include/asterisk/stringfields.h
      - copied unchanged from r7795, team/kpfleming/stringfields/include/asterisk/stringfields.h
Modified:
    trunk/astmm.c
    trunk/channels/chan_sip.c
    trunk/include/asterisk/astmm.h
    trunk/include/asterisk/pbx.h
    trunk/include/asterisk/utils.h
    trunk/pbx.c
    trunk/utils.c

Modified: trunk/astmm.c
URL: http://svn.digium.com/view/asterisk/trunk/astmm.c?rev=7797&r1=7796&r2=7797&view=diff
==============================================================================
--- trunk/astmm.c (original)
+++ trunk/astmm.c Wed Jan  4 15:54:09 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
  *
  * Mark Spencer <markster at digium.com>
  *
@@ -47,6 +47,7 @@
 #define FUNC_STRDUP	4
 #define FUNC_STRNDUP	5
 #define FUNC_VASPRINTF	6
+#define FUNC_ASPRINTF   7
 
 /* Undefine all our macros */
 #undef malloc
@@ -56,6 +57,7 @@
 #undef strndup
 #undef free
 #undef vasprintf
+#undef asprintf
 
 #define FENCE_MAGIC 0xdeadbeef
 
@@ -253,6 +255,28 @@
 	return ptr;
 }
 
+int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *fmt, ...)
+{
+	int size;
+	va_list ap, ap2;
+	char s;
+
+	*strp = NULL;
+	va_start(ap, fmt);
+	va_copy(ap2, ap);
+	size = vsnprintf(&s, 1, fmt, ap2);
+	va_end(ap2);
+	*strp = __ast_alloc_region(size + 1, FUNC_ASPRINTF, file, lineno, func);
+	if (!*strp) {
+		va_end(ap);
+		return -1;
+	}
+	vsnprintf(*strp, size + 1, fmt, ap);
+	va_end(ap);
+
+	return size;
+}
+
 int __ast_vasprintf(char **strp, const char *fmt, va_list ap, const char *file, int lineno, const char *func) 
 {
 	int size;
@@ -264,8 +288,10 @@
 	size = vsnprintf(&s, 1, fmt, ap2);
 	va_end(ap2);
 	*strp = __ast_alloc_region(size + 1, FUNC_VASPRINTF, file, lineno, func);
-	if (!*strp)
+	if (!*strp) {
+		va_end(ap);
 		return -1;
+	}
 	vsnprintf(*strp, size + 1, fmt, ap);
 
 	return size;

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=7797&r1=7796&r2=7797&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Jan  4 15:54:09 2006
@@ -86,6 +86,7 @@
 #include "asterisk/dnsmgr.h"
 #include "asterisk/devicestate.h"
 #include "asterisk/linkedlists.h"
+#include "asterisk/stringfields.h"
 
 #ifdef OSP_SUPPORT
 #include "asterisk/astosp.h"
@@ -596,8 +597,46 @@
 static struct sip_pvt {
 	ast_mutex_t lock;			/*!< Channel private lock */
 	int method;				/*!< SIP method of this packet */
-	char callid[80];			/*!< Global CallID */
-	char randdata[80];			/*!< Random data */
+	AST_DECLARE_STRING_FIELDS(
+		AST_STRING_FIELD(callid);	/*!< Global CallID */
+		AST_STRING_FIELD(randdata);	/*!< Random data */
+		AST_STRING_FIELD(accountcode);	/*!< Account code */
+		AST_STRING_FIELD(realm);	/*!< Authorization realm */
+		AST_STRING_FIELD(nonce);	/*!< Authorization nonce */
+		AST_STRING_FIELD(opaque);	/*!< Opaque nonsense */
+		AST_STRING_FIELD(qop);		/*!< Quality of Protection, since SIP wasn't complicated enough yet. */
+		AST_STRING_FIELD(domain);	/*!< Authorization domain */
+		AST_STRING_FIELD(refer_to);	/*!< Place to store REFER-TO extension */
+		AST_STRING_FIELD(referred_by);	/*!< Place to store REFERRED-BY extension */
+		AST_STRING_FIELD(refer_contact);/*!< Place to store Contact info from a REFER extension */
+		AST_STRING_FIELD(from);		/*!< The From: header */
+		AST_STRING_FIELD(useragent);	/*!< User agent in SIP request */
+		AST_STRING_FIELD(exten);	/*!< Extension where to start */
+		AST_STRING_FIELD(context);	/*!< Context for this call */
+		AST_STRING_FIELD(subscribecontext); /*!< Subscribecontext */
+		AST_STRING_FIELD(fromdomain);	/*!< Domain to show in the from field */
+		AST_STRING_FIELD(fromuser);	/*!< User to show in the user field */
+		AST_STRING_FIELD(fromname);	/*!< Name to show in the user field */
+		AST_STRING_FIELD(tohost);	/*!< Host we should put in the "to" field */
+		AST_STRING_FIELD(language);	/*!< Default language for this call */
+		AST_STRING_FIELD(musicclass);	/*!< Music on Hold class */
+		AST_STRING_FIELD(rdnis);	/*!< Referring DNIS */
+		AST_STRING_FIELD(theirtag);	/*!< Their tag */
+		AST_STRING_FIELD(username);	/*!< [user] name */
+		AST_STRING_FIELD(peername);	/*!< [peer] name, not set if [user] */
+		AST_STRING_FIELD(authname);	/*!< Who we use for authentication */
+		AST_STRING_FIELD(uri);		/*!< Original requested URI */
+		AST_STRING_FIELD(okcontacturi);	/*!< URI from the 200 OK on INVITE */
+		AST_STRING_FIELD(peersecret);	/*!< Password */
+		AST_STRING_FIELD(peermd5secret);
+		AST_STRING_FIELD(cid_num);	/*!< Caller*ID */
+		AST_STRING_FIELD(cid_name);	/*!< Caller*ID */
+		AST_STRING_FIELD(via);		/*!< Via: header */
+		AST_STRING_FIELD(fullcontact);	/*!< The Contact: that the UA registers with us */
+		AST_STRING_FIELD(our_contact);	/*!< Our contact header */
+		AST_STRING_FIELD(rpid);		/*!< Our RPID header */
+		AST_STRING_FIELD(rpid_from);	/*!< Our RPID From header */
+	);
 	struct ast_codec_pref prefs;		/*!< codec prefs */
 	unsigned int ocseq;			/*!< Current outgoing seqno */
 	unsigned int icseq;			/*!< Current incoming seqno */
@@ -626,47 +665,11 @@
 	struct sockaddr_in recv;		/*!< Received as */
 	struct in_addr ourip;			/*!< Our IP */
 	struct ast_channel *owner;		/*!< Who owns us */
-	char exten[AST_MAX_EXTENSION];		/*!< Extension where to start */
-	char refer_to[AST_MAX_EXTENSION];	/*!< Place to store REFER-TO extension */
-	char referred_by[AST_MAX_EXTENSION];	/*!< Place to store REFERRED-BY extension */
-	char refer_contact[AST_MAX_EXTENSION];	/*!< Place to store Contact info from a REFER extension */
 	struct sip_pvt *refer_call;		/*!< Call we are referring */
 	struct sip_route *route;		/*!< Head of linked list of routing steps (fm Record-Route) */
 	int route_persistant;			/*!< Is this the "real" route? */
-	char from[256];				/*!< The From: header */
-	char useragent[256];			/*!< User agent in SIP request */
-	char context[AST_MAX_CONTEXT];		/*!< Context for this call */
-	char subscribecontext[AST_MAX_CONTEXT];	/*!< Subscribecontext */
-	char fromdomain[MAXHOSTNAMELEN];	/*!< Domain to show in the from field */
-	char fromuser[AST_MAX_EXTENSION];	/*!< User to show in the user field */
-	char fromname[AST_MAX_EXTENSION];	/*!< Name to show in the user field */
-	char tohost[MAXHOSTNAMELEN];		/*!< Host we should put in the "to" field */
-	char language[MAX_LANGUAGE];		/*!< Default language for this call */
-	char musicclass[MAX_MUSICCLASS];	/*!< Music on Hold class */
-	char rdnis[256];			/*!< Referring DNIS */
-	char theirtag[256];			/*!< Their tag */
-	char username[256];			/*!< [user] name */
-	char peername[256];			/*!< [peer] name, not set if [user] */
-	char authname[256];			/*!< Who we use for authentication */
-	char uri[256];				/*!< Original requested URI */
-	char okcontacturi[256];			/*!< URI from the 200 OK on INVITE */
-	char peersecret[256];			/*!< Password */
-	char peermd5secret[256];
 	struct sip_auth *peerauth;		/*!< Realm authentication */
-	char cid_num[256];			/*!< Caller*ID */
-	char cid_name[256];			/*!< Caller*ID */
-	char via[256];				/*!< Via: header */
-	char fullcontact[128];			/*!< The Contact: that the UA registers with us */
-	char accountcode[AST_MAX_ACCOUNT_CODE];	/*!< Account code */
-	char our_contact[256];			/*!< Our contact header */
-	char *rpid;				/*!< Our RPID header */
-	char *rpid_from;			/*!< Our RPID From header */
-	char realm[MAXHOSTNAMELEN];		/*!< Authorization realm */
-	char nonce[256];			/*!< Authorization nonce */
 	int noncecount;				/*!< Nonce-count */
-	char opaque[256];			/*!< Opaque nonsense */
-	char qop[80];				/*!< Quality of Protection, since SIP wasn't complicated enough yet. */
-	char domain[MAXHOSTNAMELEN];		/*!< Authorization domain */
 	char lastmsg[256];			/*!< Last Message sent/received */
 	int amaflags;				/*!< AMA Flags */
 	int pendinginvite;			/*!< Any pending invite */
@@ -823,14 +826,22 @@
 /*! \brief sip_registry: Registrations with other SIP proxies */
 struct sip_registry {
 	ASTOBJ_COMPONENTS_FULL(struct sip_registry,1,1);
+	AST_DECLARE_STRING_FIELDS(
+		AST_STRING_FIELD(callid);	/*!< Global Call-ID */
+		AST_STRING_FIELD(realm);	/*!< Authorization realm */
+		AST_STRING_FIELD(nonce);	/*!< Authorization nonce */
+		AST_STRING_FIELD(opaque);	/*!< Opaque nonsense */
+		AST_STRING_FIELD(qop);		/*!< Quality of Protection, since SIP wasn't complicated enough yet. */
+		AST_STRING_FIELD(domain);	/*!< Authorization domain */
+		AST_STRING_FIELD(username);	/*!< Who we are registering as */
+		AST_STRING_FIELD(authuser);	/*!< Who we *authenticate* as */
+		AST_STRING_FIELD(hostname);	/*!< Domain or host we register to */
+		AST_STRING_FIELD(secret);	/*!< Password in clear text */	
+		AST_STRING_FIELD(md5secret);	/*!< Password in md5 */
+		AST_STRING_FIELD(contact);	/*!< Contact extension */
+		AST_STRING_FIELD(random);
+	);
 	int portno;			/*!<  Optional port override */
-	char username[80];		/*!<  Who we are registering as */
-	char authuser[80];		/*!< Who we *authenticate* as */
-	char hostname[MAXHOSTNAMELEN];	/*!< Domain or host we register to */
-	char secret[80];		/*!< Password in clear text */	
-	char md5secret[80];		/*!< Password in md5 */
-	char contact[256];		/*!< Contact extension */
-	char random[80];
 	int expire;			/*!< Sched ID of expiration */
 	int regattempts;		/*!< Number of attempts (since the last success) */
 	int timeout; 			/*!< sched id of sip_reg_timeout */
@@ -838,19 +849,10 @@
 	struct sip_pvt *call;		/*!< create a sip_pvt structure for each outbound "registration call" in progress */
 	int regstate;			/*!< Registration state (see above) */
 	int callid_valid;		/*!< 0 means we haven't chosen callid for this registry yet. */
-	char callid[80];		/*!< Global CallID for this registry */
 	unsigned int ocseq;		/*!< Sequence number we got to for REGISTERs for this registry */
 	struct sockaddr_in us;		/*!< Who the server thinks we are */
- 	
- 					/* Saved headers */
- 	char realm[MAXHOSTNAMELEN];	/*!< Authorization realm */
- 	char nonce[256];		/*!< Authorization nonce */
- 	char domain[MAXHOSTNAMELEN];	/*!< Authorization domain */
- 	char opaque[256];		/*!< Opaque nonsense */
- 	char qop[80];			/*!< Quality of Protection. */
 	int noncecount;			/*!< Nonce-count */
- 
- 	char lastmsg[256];		/*!< Last Message sent/received */
+	char lastmsg[256];		/*!< Last Message sent/received */
 };
 
 /*! \brief  The user list: Users and friends ---*/
@@ -891,7 +893,7 @@
 static int transmit_response(struct sip_pvt *p, char *msg, struct sip_request *req);
 static int transmit_response_with_sdp(struct sip_pvt *p, char *msg, struct sip_request *req, int retrans);
 static int transmit_response_with_unsupported(struct sip_pvt *p, char *msg, struct sip_request *req, char *unsupported);
-static int transmit_response_with_auth(struct sip_pvt *p, char *msg, struct sip_request *req, char *rand, int reliable, char *header, int stale);
+static int transmit_response_with_auth(struct sip_pvt *p, char *msg, struct sip_request *req, const char *rand, int reliable, char *header, int stale);
 static int transmit_request(struct sip_pvt *p, int sipmethod, int inc, int reliable, int newbranch);
 static int transmit_request_with_auth(struct sip_pvt *p, int sipmethod, int inc, int reliable, int newbranch);
 static int transmit_invite(struct sip_pvt *p, int sipmethod, int sendsdp, int init);
@@ -926,7 +928,7 @@
 static int sip_senddigit(struct ast_channel *ast, char digit);
 static int clear_realm_authentication(struct sip_auth *authlist);                            /* Clear realm authentication list (at reload) */
 static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char *configuration, int lineno);   /* Add realm authentication in list */
-static struct sip_auth *find_realm_authentication(struct sip_auth *authlist, char *realm);         /* Find authentication for a specific realm */
+static struct sip_auth *find_realm_authentication(struct sip_auth *authlist, const char *realm);         /* Find authentication for a specific realm */
 static int check_sip_domain(const char *domain, char *context, size_t len); /* Check if domain is one of our local domains */
 static void append_date(struct sip_request *req);	/* Append date to SIP packet */
 static int determine_firstline_parts(struct sip_request *req);
@@ -1084,15 +1086,15 @@
 static void sip_destroy(struct sip_pvt *p);
 
 /*! \brief  build_via: Build a Via header for a request ---*/
-static void build_via(struct sip_pvt *p, char *buf, int len)
+static void build_via(struct sip_pvt *p)
 {
 	char iabuf[INET_ADDRSTRLEN];
 	/* Work around buggy UNIDEN UIP200 firmware */
-	const char *rport= ast_test_flag(p, SIP_NAT) & SIP_NAT_RFC3581 ? ";rport" : "";
+	const char *rport = ast_test_flag(p, SIP_NAT) & SIP_NAT_RFC3581 ? ";rport" : "";
 
 	/* z9hG4bK is a magic cookie.  See RFC 3261 section 8.1.1.7 */
-	snprintf(buf, len, "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x%s",
-		ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch, rport);
+	ast_string_field_build(p, via, "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x%s",
+			       ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch, rport);
 }
 
 /*! \brief  ast_sip_ouraddrfor: NAT fix - decide which IP address to use for ASterisk server? ---*/
@@ -1857,28 +1859,31 @@
 		ast_log(LOG_DEBUG, "Setting NAT on VRTP to %d\n", (ast_test_flag(r, SIP_NAT) & SIP_NAT_ROUTE));
 		ast_rtp_setnat(r->vrtp, (ast_test_flag(r, SIP_NAT) & SIP_NAT_ROUTE));
 	}
-	ast_copy_string(r->peername, peer->username, sizeof(r->peername));
-	ast_copy_string(r->authname, peer->username, sizeof(r->authname));
-	ast_copy_string(r->username, peer->username, sizeof(r->username));
-	ast_copy_string(r->peersecret, peer->secret, sizeof(r->peersecret));
-	ast_copy_string(r->peermd5secret, peer->md5secret, sizeof(r->peermd5secret));
-	ast_copy_string(r->tohost, peer->tohost, sizeof(r->tohost));
-	ast_copy_string(r->fullcontact, peer->fullcontact, sizeof(r->fullcontact));
+	ast_string_field_set(r, peername, peer->username);
+	ast_string_field_set(r, authname, peer->username);
+	ast_string_field_set(r, username, peer->username);
+	ast_string_field_set(r, peersecret, peer->secret);
+	ast_string_field_set(r, peermd5secret, peer->md5secret);
+	ast_string_field_set(r, tohost, peer->tohost);
+	ast_string_field_set(r, fullcontact, peer->fullcontact);
 	if (!r->initreq.headers && !ast_strlen_zero(peer->fromdomain)) {
 		if ((callhost = strchr(r->callid, '@'))) {
 			strncpy(callhost + 1, peer->fromdomain, sizeof(r->callid) - (callhost - r->callid) - 2);
 		}
 	}
 	if (ast_strlen_zero(r->tohost)) {
+		char iabuf[INET_ADDRSTRLEN];
+
 		if (peer->addr.sin_addr.s_addr)
-			ast_inet_ntoa(r->tohost, sizeof(r->tohost), peer->addr.sin_addr);
+			ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr);
 		else
-			ast_inet_ntoa(r->tohost, sizeof(r->tohost), peer->defaddr.sin_addr);
+			ast_inet_ntoa(iabuf, sizeof(iabuf), peer->defaddr.sin_addr);
+		ast_string_field_set(r, tohost, iabuf);
 	}
 	if (!ast_strlen_zero(peer->fromdomain))
-		ast_copy_string(r->fromdomain, peer->fromdomain, sizeof(r->fromdomain));
+		ast_string_field_set(r, fromdomain, peer->fromdomain);
 	if (!ast_strlen_zero(peer->fromuser))
-		ast_copy_string(r->fromuser, peer->fromuser, sizeof(r->fromuser));
+		ast_string_field_set(r, fromuser, peer->fromuser);
 	r->maxtime = peer->maxms;
 	r->callgroup = peer->callgroup;
 	r->pickupgroup = peer->pickupgroup;
@@ -1889,7 +1894,7 @@
 		r->noncodeccapability |= AST_RTP_DTMF;
 	else
 		r->noncodeccapability &= ~AST_RTP_DTMF;
-	ast_copy_string(r->context, peer->context,sizeof(r->context));
+	ast_string_field_set(r, context, peer->context);
 	r->rtptimeout = peer->rtptimeout;
 	r->rtpholdtimeout = peer->rtpholdtimeout;
 	r->rtpkeepalive = peer->rtpkeepalive;
@@ -1902,7 +1907,7 @@
 /*! \brief  create_addr: create address structure from peer name
  *      Or, if peer not found, find it in the global DNS 
  *      returns TRUE (-1) on failure, FALSE on success */
-static int create_addr(struct sip_pvt *dialog, char *opeer)
+static int create_addr(struct sip_pvt *dialog, const char *opeer)
 {
 	struct hostent *hp;
 	struct ast_hostent ahp;
@@ -1950,7 +1955,7 @@
 		}
 		hp = ast_gethostbyname(hostn, &ahp);
 		if (hp) {
-			ast_copy_string(dialog->tohost, peer, sizeof(dialog->tohost));
+			ast_string_field_set(dialog, tohost, peer);
 			memcpy(&dialog->sa.sin_addr, hp->h_addr, sizeof(dialog->sa.sin_addr));
 			dialog->sa.sin_port = htons(portno);
 			memcpy(&dialog->recv, &dialog->sa, sizeof(dialog->recv));
@@ -2073,6 +2078,7 @@
 		ast_sched_del(sched, reg->expire);
 	if (reg->timeout > -1)
 		ast_sched_del(sched, reg->timeout);
+	ast_string_field_free_all(reg);
 	regobjs--;
 	free(reg);
 	
@@ -2115,12 +2121,6 @@
 			p->registry->call = NULL;
 		ASTOBJ_UNREF(p->registry,sip_registry_destroy);
 	}
-
-	if (p->rpid)
-		free(p->rpid);
-
-	if (p->rpid_from)
-		free(p->rpid_from);
 
 	/* Unlink us from the owner if we have one */
 	if (p->owner) {
@@ -2173,6 +2173,9 @@
 		p->chanvars = NULL;
 	}
 	ast_mutex_destroy(&p->lock);
+
+	ast_string_field_free_all(p);
+
 	free(p);
 }
 
@@ -2759,7 +2762,7 @@
 
 /*! \brief  sip_new: Initiate a call in the SIP channel */
 /*      called from sip_request_call (calls from the pbx ) */
-static struct ast_channel *sip_new(struct sip_pvt *i, int state, char *title)
+static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *title)
 {
 	struct ast_channel *tmp;
 	struct ast_variable *v = NULL;
@@ -3036,24 +3039,46 @@
 	return fr;
 }
 
-/*! \brief  build_callid: Build SIP CALLID header ---*/
-static void build_callid(char *callid, int len, struct in_addr ourip, char *fromdomain)
-{
-	int res;
-	int val;
+/*! \brief  build_callid_pvt: Build SIP Call-ID value for a non-REGISTER transaction ---*/
+static void build_callid_pvt(struct sip_pvt *pvt)
+{
+	int val[4];
 	int x;
 	char iabuf[INET_ADDRSTRLEN];
-	for (x=0; x<4; x++) {
-		val = thread_safe_rand();
-		res = snprintf(callid, len, "%08x", val);
-		len -= res;
-		callid += res;
-	}
-	if (!ast_strlen_zero(fromdomain))
-		snprintf(callid, len, "@%s", fromdomain);
+
+	for (x=0; x<4; x++)
+		val[x] = thread_safe_rand();
+
+	if (ast_strlen_zero(pvt->fromdomain))
+		/* It's not important that we really use our right IP here... */
+		ast_string_field_build(pvt, callid, "%08x%08x%08x%08x@%s",
+				       val[0], val[1], val[2], val[3],
+				       ast_inet_ntoa(iabuf, sizeof(iabuf), pvt->ourip));
 	else
-	/* It's not important that we really use our right IP here... */
-		snprintf(callid, len, "@%s", ast_inet_ntoa(iabuf, sizeof(iabuf), ourip));
+		ast_string_field_build(pvt, callid, "%08x%08x%08x%08x@%s",
+				       val[0], val[1], val[2], val[3],
+				       pvt->fromdomain);
+}
+
+/*! \brief  build_callid_registry: Build SIP Call-ID value for a REGISTER transaction ---*/
+static void build_callid_registry(struct sip_registry *reg, struct in_addr ourip, const char *fromdomain)
+{
+	int val[4];
+	int x;
+	char iabuf[INET_ADDRSTRLEN];
+
+	for (x=0; x<4; x++)
+		val[x] = thread_safe_rand();
+
+	if (ast_strlen_zero(fromdomain))
+		/* It's not important that we really use our right IP here... */
+		ast_string_field_build(reg, callid, "%08x%08x%08x%08x@%s",
+				       val[0], val[1], val[2], val[3],
+				       ast_inet_ntoa(iabuf, sizeof(iabuf), ourip));
+	else
+		ast_string_field_build(reg, callid, "%08x%08x%08x%08x@%s",
+				       val[0], val[1], val[2], val[3],
+				       fromdomain);
 }
 
 static void make_our_tag(char *tagbuf, size_t len)
@@ -3062,12 +3087,18 @@
 }
 
 /*! \brief  sip_alloc: Allocate SIP_PVT structure and set defaults ---*/
-static struct sip_pvt *sip_alloc(char *callid, struct sockaddr_in *sin, int useglobal_nat, const int intended_method)
+static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *sin,
+				 int useglobal_nat, const int intended_method)
 {
 	struct sip_pvt *p;
 
 	if (!(p = calloc(1, sizeof(*p))))
 		return NULL;
+
+	if (ast_string_field_init(p)) {
+		free(p);
+		return NULL;
+	}
 
 	ast_mutex_init(&p->lock);
 
@@ -3129,19 +3160,19 @@
 	}
 
 	if (p->method != SIP_REGISTER)
-		ast_copy_string(p->fromdomain, default_fromdomain, sizeof(p->fromdomain));
-	build_via(p, p->via, sizeof(p->via));
+		ast_string_field_set(p, fromdomain, default_fromdomain);
+	build_via(p);
 	if (!callid)
-		build_callid(p->callid, sizeof(p->callid), p->ourip, p->fromdomain);
+		build_callid_pvt(p);
 	else
-		ast_copy_string(p->callid, callid, sizeof(p->callid));
+		ast_string_field_set(p, callid, callid);
 	ast_copy_flags(p, &global_flags, SIP_FLAGS_TO_COPY);
 	/* Assign default music on hold class */
-	strcpy(p->musicclass, global_musicclass);
+	ast_string_field_set(p, musicclass, global_musicclass);
 	p->capability = global_capability;
 	if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO))
 		p->noncodeccapability |= AST_RTP_DTMF;
-	strcpy(p->context, default_context);
+	ast_string_field_set(p, context, default_context);
 
 	/* Add to active dialog list */
 	ast_mutex_lock(&iflock);
@@ -3274,23 +3305,28 @@
 		ast_log(LOG_WARNING, "%s is not a valid port number at line %d\n", porta, lineno);
 		return -1;
 	}
-	reg = malloc(sizeof(struct sip_registry));
-	if (!reg) {
+	if (!(reg = calloc(1, sizeof(*reg)))) {
 		ast_log(LOG_ERROR, "Out of memory. Can't allocate SIP registry entry\n");
 		return -1;
 	}
-	memset(reg, 0, sizeof(struct sip_registry));
+
+	if (ast_string_field_init(reg)) {
+		ast_log(LOG_ERROR, "Out of memory. Can't allocate SIP registry entry\n");
+		free(reg);
+		return -1;
+	}
+
 	regobjs++;
 	ASTOBJ_INIT(reg);
-	ast_copy_string(reg->contact, contact, sizeof(reg->contact));
+	ast_string_field_set(reg, contact, contact);
 	if (username)
-		ast_copy_string(reg->username, username, sizeof(reg->username));
+		ast_string_field_set(reg, username, username);
 	if (hostname)
-		ast_copy_string(reg->hostname, hostname, sizeof(reg->hostname));
+		ast_string_field_set(reg, hostname, hostname);
 	if (authuser)
-		ast_copy_string(reg->authuser, authuser, sizeof(reg->authuser));
+		ast_string_field_set(reg, authuser, authuser);
 	if (secret)
-		ast_copy_string(reg->secret, secret, sizeof(reg->secret));
+		ast_string_field_set(reg, secret, secret);
 	reg->expire = -1;
 	reg->timeout =  -1;
 	reg->refresh = default_expiry;
@@ -3993,7 +4029,7 @@
 }
 
 /*! \brief  init_req: Initialize SIP request ---*/
-static int init_req(struct sip_request *req, int sipmethod, char *recip)
+static int init_req(struct sip_request *req, int sipmethod, const char *recip)
 {
 	/* Initialize a response */
 	if (req->headers || req->len) {
@@ -4064,7 +4100,8 @@
 	char stripped[80];
 	char tmp[80];
 	char newto[256];
-	char *c, *n;
+	const char *c;
+	char *n;
 	char *ot, *of;
 	int is_strict = 0;	/* Strict routing flag */
 
@@ -4079,7 +4116,7 @@
 	
 	if (newbranch) {
 		p->branch ^= thread_safe_rand();
-		build_via(p, p->via, sizeof(p->via));
+		build_via(p);
 	}
 
 	/* Check for strict or loose router */
@@ -4101,8 +4138,8 @@
 		c = p->uri;
 	} else {
 		/* We have no URI, use To: or From:  header as URI (depending on direction) */
-		c = get_header(orig, (ast_test_flag(p, SIP_OUTGOING)) ? "To" : "From");
-		ast_copy_string(stripped, c, sizeof(stripped));
+		ast_copy_string(stripped, get_header(orig, (ast_test_flag(p, SIP_OUTGOING)) ? "To" : "From"),
+				sizeof(stripped));
 		c = get_in_brackets(stripped);
 		n = strchr(c, ';');
 		if (n)
@@ -4237,7 +4274,7 @@
 }
 
 /* transmit_response_with_auth: Respond with authorization request */
-static int transmit_response_with_auth(struct sip_pvt *p, char *msg, struct sip_request *req, char *randdata, int reliable, char *header, int stale)
+static int transmit_response_with_auth(struct sip_pvt *p, char *msg, struct sip_request *req, const char *randdata, int reliable, char *header, int stale)
 {
 	struct sip_request resp;
 	char tmp[256];
@@ -4651,7 +4688,7 @@
 	if (n)
 		*n = '\0';
 	if (!ast_strlen_zero(c))
-		ast_copy_string(p->uri, c, sizeof(p->uri));
+		ast_string_field_set(p, uri, c);
 }
 
 /*! \brief  build_contact: Build contact header - the contact header we send out ---*/
@@ -4661,9 +4698,9 @@
 
 	/* Construct Contact: header */
 	if (ourport != 5060)	/* Needs to be 5060, according to the RFC */
-		snprintf(p->our_contact, sizeof(p->our_contact), "<sip:%s%s%s:%d>", p->exten, ast_strlen_zero(p->exten) ? "" : "@", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport);
+		ast_string_field_build(p, our_contact, "<sip:%s%s%s:%d>", p->exten, ast_strlen_zero(p->exten) ? "" : "@", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport);
 	else
-		snprintf(p->our_contact, sizeof(p->our_contact), "<sip:%s%s%s>", p->exten, ast_strlen_zero(p->exten) ? "" : "@", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip));
+		ast_string_field_build(p, our_contact, "<sip:%s%s%s>", p->exten, ast_strlen_zero(p->exten) ? "" : "@", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip));
 }
 
 /*! \brief  build_rpid: Build the Remote Party-ID & From using callingpres options ---*/
@@ -4739,12 +4776,11 @@
 	snprintf(buf, sizeof(buf), "\"%s\" <sip:%s@%s>", clin, clid, fromdomain);
 	if (send_pres_tags)
 		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ";privacy=%s;screen=%s", privacy, screen);
-	p->rpid = strdup(buf);
-
-	snprintf(buf, sizeof(buf), "\"%s\" <sip:%s@%s>;tag=%s", clin,
-		 ast_strlen_zero(p->fromuser) ? clid : p->fromuser,
-		 fromdomain, p->tag);
-	p->rpid_from = strdup(buf);
+	ast_string_field_set(p, rpid, buf);
+
+	ast_string_field_build(p, rpid_from, "\"%s\" <sip:%s@%s>;tag=%s", clin,
+			       ast_strlen_zero(p->fromuser) ? clid : p->fromuser,
+			       fromdomain, p->tag);
 }
 
 /*! \brief  initreqprep: Initiate new SIP request to peer/user ---*/
@@ -4758,7 +4794,7 @@
 	char tmp[BUFSIZ/2];
 	char tmp2[BUFSIZ/2];
 	char iabuf[INET_ADDRSTRLEN];
-	char *l = NULL, *n = NULL;
+	const char *l = NULL, *n = NULL;
 	int x;
 	char urioptions[256]="";
 
@@ -4806,13 +4842,13 @@
 	if (!ast_strlen_zero(p->fromuser))
 		l = p->fromuser;
 	else /* Save for any further attempts */
-		ast_copy_string(p->fromuser, l, sizeof(p->fromuser));
+		ast_string_field_set(p, fromuser, l);
 
 	/* Allow user to be overridden */
 	if (!ast_strlen_zero(p->fromname))
 		n = p->fromname;
 	else /* Save for any further attempts */
-		ast_copy_string(p->fromname, n, sizeof(p->fromname));
+		ast_string_field_set(p, fromname, n);
 
 	if (pedanticsipchecking) {
 		ast_uri_encode(n, tmp, sizeof(tmp), 0);
@@ -4850,8 +4886,8 @@
 	/* If custom URI options have been provided, append them */
 	if (p->options && p->options->uri_options)
 		ast_build_string(&invite, &invite_max, ";%s", p->options->uri_options);
-
-	ast_copy_string(p->uri, invite_buf, sizeof(p->uri));
+	
+	ast_string_field_set(p, uri, invite_buf);
 
 	/* If there is a VXML URL append it to the SIP URL */
 	if (p->options && p->options->vxml_url) {
@@ -4874,7 +4910,7 @@
 		add_header(req, "From", from);
 	}
 	add_header(req, "To", to);
-	ast_copy_string(p->exten, l, sizeof(p->exten));
+	ast_string_field_set(p, exten, l);
 	build_contact(p);
 	add_header(req, "Contact", p->our_contact);
 	add_header(req, "Call-ID", p->callid);
@@ -4894,7 +4930,7 @@
 	if (init) {
 		/* Bump branch even on initial requests */
 		p->branch ^= thread_safe_rand();
-		build_via(p, p->via, sizeof(p->via));
+		build_via(p);
 		if (init > 1)
 			initreqprep(&req, p, sipmethod);
 		else
@@ -5340,7 +5376,6 @@
 	char from[256];
 	char to[256];
 	char tmp[80];
-	char via[80];
 	char addr[80];
 	struct sip_pvt *p;
 
@@ -5357,12 +5392,12 @@
 		} else {
 			p = r->call;
 			make_our_tag(p->tag, sizeof(p->tag));	/* create a new local tag for every register attempt */
-			p->theirtag[0]='\0';	/* forget their old tag, so we don't match tags when getting response */
+			ast_string_field_free(p, theirtag);	/* forget their old tag, so we don't match tags when getting response */
 		}
 	} else {
 		/* Build callid for registration if we haven't registered before */
 		if (!r->callid_valid) {
-			build_callid(r->callid, sizeof(r->callid), __ourip, default_fromdomain);
+			build_callid_registry(r, __ourip, default_fromdomain);
 			r->callid_valid = 1;
 		}
 		/* Allocate SIP packet for registration */
@@ -5390,32 +5425,32 @@
 			return 0;
 		}
 		/* Copy back Call-ID in case create_addr changed it */
-		ast_copy_string(r->callid, p->callid, sizeof(r->callid));
+		ast_string_field_set(r, callid, p->callid);
 		if (r->portno)
 			p->sa.sin_port = htons(r->portno);
 		ast_set_flag(p, SIP_OUTGOING);	/* Registration is outgoing call */
 		r->call=p;			/* Save pointer to SIP packet */
 		p->registry=ASTOBJ_REF(r);	/* Add pointer to registry in packet */
 		if (!ast_strlen_zero(r->secret))	/* Secret (password) */
-			ast_copy_string(p->peersecret, r->secret, sizeof(p->peersecret));
+			ast_string_field_set(p, peersecret, r->secret);
 		if (!ast_strlen_zero(r->md5secret))
-			ast_copy_string(p->peermd5secret, r->md5secret, sizeof(p->peermd5secret));
+			ast_string_field_set(p, peermd5secret, r->md5secret);
 		/* User name in this realm  
 		- if authuser is set, use that, otherwise use username */
 		if (!ast_strlen_zero(r->authuser)) {	
-			ast_copy_string(p->peername, r->authuser, sizeof(p->peername));
-			ast_copy_string(p->authname, r->authuser, sizeof(p->authname));
+			ast_string_field_set(p, peername, r->authuser);
+			ast_string_field_set(p, authname, r->authuser);
 		} else {
 			if (!ast_strlen_zero(r->username)) {
-				ast_copy_string(p->peername, r->username, sizeof(p->peername));
-				ast_copy_string(p->authname, r->username, sizeof(p->authname));
-				ast_copy_string(p->fromuser, r->username, sizeof(p->fromuser));
+				ast_string_field_set(p, peername, r->username);
+				ast_string_field_set(p, authname, r->username);
+				ast_string_field_set(p, fromuser, r->username);
 			}
 		}
 		if (!ast_strlen_zero(r->username))
-			ast_copy_string(p->username, r->username, sizeof(p->username));
+			ast_string_field_set(p, username, r->username);
 		/* Save extension in packet */
-		ast_copy_string(p->exten, r->contact, sizeof(p->exten));
+		ast_string_field_set(p, exten, r->contact);
 
 		/*
 		  check which address we should use in our contact header 
@@ -5457,7 +5492,7 @@
 		snprintf(addr, sizeof(addr), "sip:%s", p->fromdomain);
 	else
 		snprintf(addr, sizeof(addr), "sip:%s", r->hostname);
-	ast_copy_string(p->uri, addr, sizeof(p->uri));
+	ast_string_field_set(p, uri, addr);
 
 	p->branch ^= thread_safe_rand();
 
@@ -5468,8 +5503,8 @@
 	snprintf(tmp, sizeof(tmp), "%u %s", ++r->ocseq, sip_methods[sipmethod].text);
 	p->ocseq = r->ocseq;
 
-	build_via(p, via, sizeof(via));
-	add_header(&req, "Via", via);
+	build_via(p);
+	add_header(&req, "Via", p->via);
 	add_header(&req, "From", from);
 	add_header(&req, "To", to);
 	add_header(&req, "Call-ID", p->callid);
@@ -5486,11 +5521,11 @@
 		/* We have auth data to reuse, build a digest header! */
 		if (sipdebug)
 			ast_log(LOG_DEBUG, "   >>> Re-using Auth data for %s@%s\n", r->username, r->hostname);
-		ast_copy_string(p->realm, r->realm, sizeof(p->realm));
-		ast_copy_string(p->nonce, r->nonce, sizeof(p->nonce));
-		ast_copy_string(p->domain, r->domain, sizeof(p->domain));
-		ast_copy_string(p->opaque, r->opaque, sizeof(p->opaque));
-		ast_copy_string(p->qop, r->qop, sizeof(p->qop));
+		ast_string_field_set(p, realm, r->realm);
+		ast_string_field_set(p, nonce, r->nonce);
+		ast_string_field_set(p, domain, r->domain);
+		ast_string_field_set(p, opaque, r->opaque);
+		ast_string_field_set(p, qop, r->qop);
 		p->noncecount = r->noncecount++;
 
 		memset(digest,0,sizeof(digest));
@@ -5543,7 +5578,7 @@
 		of = get_header(&p->initreq, "From");
 	ast_copy_string(from, of, sizeof(from));
 	of = get_in_brackets(from);
-	ast_copy_string(p->from,of,sizeof(p->from));
+	ast_string_field_set(p, from, of);
 	if (strncmp(of, "sip:", 4)) {
 		ast_log(LOG_NOTICE, "From address missing 'sip:', using it anyway\n");
 	} else
@@ -5562,8 +5597,8 @@
 	}
 
 	/* save in case we get 407 challenge */
-	ast_copy_string(p->refer_to, referto, sizeof(p->refer_to));
-	ast_copy_string(p->referred_by, p->our_contact, sizeof(p->referred_by));
+	ast_string_field_set(p, refer_to, referto);
+	ast_string_field_set(p, referred_by, p->our_contact);
 
 	reqprep(&req, p, SIP_REFER, 0, 1);
 	add_header(&req, "Refer-To", referto);
@@ -5608,7 +5643,7 @@
 	struct sip_request resp;
 
 	reqprep(&resp, p, sipmethod, seqno, newbranch);
-	if (*p->realm) {
+	if (!ast_strlen_zero(p->realm)) {
 		char digest[1024];
 
 		memset(digest, 0, sizeof(digest));
@@ -5753,10 +5788,10 @@
 	c = get_in_brackets(contact);
 
 	/* Save full contact to call pvt for later bye or re-invite */
-	ast_copy_string(pvt->fullcontact, c, sizeof(pvt->fullcontact));	
+	ast_string_field_set(pvt, fullcontact, c);
 
 	/* Save URI for later ACKs, BYE or RE-invites */
-	ast_copy_string(pvt->okcontacturi, c, sizeof(pvt->okcontacturi));
+	ast_string_field_set(pvt, okcontacturi, c);
 	
 	/* Make sure it's a SIP URL */
 	if (strncasecmp(c, "sip:", 4)) {
@@ -5885,7 +5920,7 @@
 	}
 	ast_copy_string(p->fullcontact, c, sizeof(p->fullcontact));
 	/* For the 200 OK, we should use the received contact */
-	snprintf(pvt->our_contact, sizeof(pvt->our_contact) - 1, "<%s>", c);
+	ast_string_field_build(pvt, our_contact, "<%s>", c);
 	/* Make sure it's a SIP URL */
 	if (strncasecmp(c, "sip:", 4)) {
 		ast_log(LOG_NOTICE, "'%s' is not a valid SIP contact (missing sip:) trying to use anyway\n", c);
@@ -6113,7 +6148,9 @@
 /*! \brief  check_auth: Check user authorization from peer definition ---*/
 /*      Some actions, like REGISTER and INVITEs from peers require
         authentication (if peer have secret set) */
-static int check_auth(struct sip_pvt *p, struct sip_request *req, char *randdata, int randlen, char *username, char *secret, char *md5secret, int sipmethod, char *uri, int reliable, int ignore)
+static int check_auth(struct sip_pvt *p, struct sip_request *req, const char *username,
+		      const char *secret, const char *md5secret, int sipmethod,
+		      char *uri, int reliable, int ignore)
 {
 	int res = -1;
 	char *response = "407 Proxy Authentication Required";
@@ -6178,22 +6215,22 @@
  	}
 #endif	
 	authtoken =  get_header(req, reqheader);	
-	if (ignore && !ast_strlen_zero(randdata) && ast_strlen_zero(authtoken)) {
+	if (ignore && !ast_strlen_zero(p->randdata) && ast_strlen_zero(authtoken)) {
 		/* This is a retransmitted invite/register/etc, don't reconstruct authentication
 		   information */
-		if (!ast_strlen_zero(randdata)) {
+		if (!ast_strlen_zero(p->randdata)) {
 			if (!reliable) {
 				/* Resend message if this was NOT a reliable delivery.   Otherwise the
 				   retransmission should get it */
-				transmit_response_with_auth(p, response, req, randdata, reliable, respheader, 0);
+				transmit_response_with_auth(p, response, req, p->randdata, reliable, respheader, 0);
 				/* Schedule auto destroy in 15 seconds */
 				sip_scheddestroy(p, 15000);
 			}
 			res = 1;
 		}
-	} else if (ast_strlen_zero(randdata) || ast_strlen_zero(authtoken)) {
-		snprintf(randdata, randlen, "%08x", thread_safe_rand());
-		transmit_response_with_auth(p, response, req, randdata, reliable, respheader, 0);
+	} else if (ast_strlen_zero(p->randdata) || ast_strlen_zero(authtoken)) {
+		ast_string_field_build(p, randdata, "%08x", thread_safe_rand());
+		transmit_response_with_auth(p, response, req, p->randdata, reliable, respheader, 0);
 		/* Schedule auto destroy in 15 seconds */
 		sip_scheddestroy(p, 15000);
 		res = 1;
@@ -6214,7 +6251,7 @@
 		char *nonce = "";
 		char *digestusername = "";
 		int  wrongnonce = 0;
-		char *usednonce = randdata;
+		const char *usednonce = p->randdata;
 
 		/* Find their response among the mess that we'r sent for comparison */
 		ast_copy_string(tmp, authtoken, sizeof(tmp));
@@ -6284,7 +6321,7 @@
 		}
 
 		/* Verify nonce from request matches our nonce.  If not, send 401 with new nonce */
-		if (strncasecmp(randdata, nonce, randlen)) {
+		if (strcasecmp(p->randdata, nonce)) {
 			wrongnonce = 1;
 			usednonce = nonce;
 		}
@@ -6307,18 +6344,17 @@
 		ast_md5_hash(resp_hash, resp);
 
 		if (wrongnonce) {
-
-			snprintf(randdata, randlen, "%08x", thread_safe_rand());
+			ast_string_field_build(p, randdata, "%08x", thread_safe_rand());
 			if (ua_hash && !strncasecmp(ua_hash, resp_hash, strlen(resp_hash))) {
 				if (sipdebug)
 					ast_log(LOG_NOTICE, "stale nonce received from '%s'\n", get_header(req, "To"));
 				/* We got working auth token, based on stale nonce . */
-				transmit_response_with_auth(p, response, req, randdata, reliable, respheader, 1);
+				transmit_response_with_auth(p, response, req, p->randdata, reliable, respheader, 1);
 			} else {
 				/* Everything was wrong, so give the device one more try with a new challenge */
 				if (sipdebug)
 					ast_log(LOG_NOTICE, "Bad authentication received from '%s'\n", get_header(req, "To"));
-				transmit_response_with_auth(p, response, req, randdata, reliable, respheader, 0);
+				transmit_response_with_auth(p, response, req, p->randdata, reliable, respheader, 0);
 			}
 
 			/* Schedule auto destroy in 15 seconds */
@@ -6412,7 +6448,7 @@
 		}
 	}
 
-	ast_copy_string(p->exten, name, sizeof(p->exten));
+	ast_string_field_set(p, exten, name);
 	build_contact(p);
 	peer = find_peer(name, NULL, 1);
 	if (!(peer && ast_apply_ha(peer->ha, sin))) {
@@ -6425,7 +6461,7 @@
 		} else {
 			ast_copy_flags(p, peer, SIP_NAT);
 			transmit_response(p, "100 Trying", req);
-			if (!(res = check_auth(p, req, p->randdata, sizeof(p->randdata), peer->name, peer->secret, peer->md5secret, SIP_REGISTER, uri, 0, ignore))) {
+			if (!(res = check_auth(p, req, peer->name, peer->secret, peer->md5secret, SIP_REGISTER, uri, 0, ignore))) {
 				sip_cancel_destroy(p);
 				switch (parse_register_contact(p, peer, req)) {
 				case PARSE_REGISTER_FAILED:
@@ -6531,7 +6567,7 @@
 	}
 	if (sip_debug_test_pvt(p))
 		ast_verbose("RDNIS is %s\n", c);
-	ast_copy_string(p->rdnis, c, sizeof(p->rdnis));
+	ast_string_field_set(p, rdnis, c);
 
 	return 0;
 }
@@ -6581,7 +6617,7 @@
 		colon = strchr(a, ':'); /* Remove :port */
 		if (colon)
 			*colon = '\0';
-		ast_copy_string(p->domain, a, sizeof(p->domain));
+		ast_string_field_set(p, domain, a);
 	}
 	/* Skip any options */
 	if ((a = strchr(uri, ';'))) {
@@ -6600,7 +6636,7 @@
 		}
 		/* If we have a context defined, overwrite the original context */
 		if (!ast_strlen_zero(domain_context))
-			ast_copy_string(p->context, domain_context, sizeof(p->context));
+			ast_string_field_set(p, context, domain_context);
 	}
 
 	if (from) {
@@ -6608,9 +6644,9 @@
 			*a = '\0';
 		if ((a = strchr(from, '@'))) {
 			*a = '\0';
-			ast_copy_string(p->fromdomain, a + 1, sizeof(p->fromdomain));
+			ast_string_field_set(p, fromdomain, a + 1);
 		} else
-			ast_copy_string(p->fromdomain, from, sizeof(p->fromdomain));
+			ast_string_field_set(p, fromdomain, from);
 	}
 	if (sip_debug_test_pvt(p))
 		ast_verbose("Looking for %s in %s (domain %s)\n", uri, p->context, p->domain);
@@ -6619,7 +6655,7 @@
 	if (ast_exists_extension(NULL, p->context, uri, 1, from) ||
 		!strcmp(uri, ast_pickup_ext())) {
 		if (!oreq)
-			ast_copy_string(p->exten, uri, sizeof(p->exten));
+			ast_string_field_set(p, exten, uri);
 		return 0;
 	}
 
@@ -6755,9 +6791,9 @@
 		/* This is a supervised transfer */

[... 722 lines stripped ...]


More information about the asterisk-commits mailing list