[asterisk-commits] mmichelson: branch mmichelson/issue14220 r169043 - /team/mmichelson/issue1422...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 16 17:38:39 CST 2009


Author: mmichelson
Date: Fri Jan 16 17:38:38 2009
New Revision: 169043

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=169043
Log:
Checking because I have to leave soon

* convert rlPart1, rlPart2, header, and line to be ptrdiff_t instead
  of char*. ptrdiff_t makes sense to me since these values will be the
  results of pointer arithmetic.

* Convert the __get_header function to act properly
* Convert the copy_request function to act properly

The parse_request and determine_firstline_parts functions are *not*
going to be fun :(


Modified:
    team/mmichelson/issue14220/channels/chan_sip.c

Modified: team/mmichelson/issue14220/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/issue14220/channels/chan_sip.c?view=diff&rev=169043&r1=169042&r2=169043
==============================================================================
--- team/mmichelson/issue14220/channels/chan_sip.c (original)
+++ team/mmichelson/issue14220/channels/chan_sip.c Fri Jan 16 17:38:38 2009
@@ -1187,8 +1187,8 @@
  * \endverbatim
  */
 struct sip_request {
-	char *rlPart1; 	        /*!< SIP Method Name or "SIP/2.0" protocol version */
-	char *rlPart2; 	        /*!< The Request URI or Response Status */
+	ptrdiff_t rlPart1; 	        /*!< SIP Method Name or "SIP/2.0" protocol version */
+	ptrdiff_t rlPart2; 	        /*!< The Request URI or Response Status */
 	int len;                /*!< bytes used in data[], excluding trailing null terminator. Rarely used. */
 	int headers;            /*!< # of SIP Headers */
 	int method;             /*!< Method of this request */
@@ -1198,8 +1198,8 @@
 	char debug;		/*!< print extra debugging if non zero */
 	char has_to_tag;	/*!< non-zero if packet has To: tag */
 	char ignore;		/*!< if non-zero This is a re-transmit, ignore it */
-	char *header[SIP_MAX_HEADERS];
-	char *line[SIP_MAX_LINES];
+	ptrdiff_t header[SIP_MAX_HEADERS];
+	ptrdiff_t line[SIP_MAX_LINES];
 	struct ast_str *data;	
 	/* XXX Do we need to unref socket.ser when the request goes away? */
 	struct sip_socket socket;	/*!< The socket used for this request */
@@ -6328,9 +6328,10 @@
 	 */
 	for (pass = 0; name && pass < 2;pass++) {
 		int x, len = strlen(name);
-		for (x=*start; x<req->headers; x++) {
-			if (!strncasecmp(req->header[x], name, len)) {
-				char *r = req->header[x] + len;	/* skip name */
+		for (x = *start; x < req->headers; x++) {
+			char *header = req->data->str + req->header[x];
+			if (!strncasecmp(header, name, len)) {
+				char *r = header + len;	/* skip name */
 				if (sip_cfg.pedanticsipchecking)
 					r = ast_skip_blanks(r);
 
@@ -9386,17 +9387,10 @@
 		
 	memcpy(dst->data->str, src->data->str, src->data->used + 1);
 	dst->data->used = src->data->used;
-	offset = ((void *)dst->data->str) - ((void *)src->data->str);
-	/* Now fix pointer arithmetic */
-	for (x = 0; x < src->headers; x++)
-		dst->header[x] += offset;
-	for (x = 0; x < src->lines; x++)
-		dst->line[x] += offset;
-	/* On some occasions this function is called without parse_request being called first so lets not create an invalid pointer */
-	if (src->rlPart1)
-		dst->rlPart1 += offset;
-	if (src->rlPart2)
-		dst->rlPart2 += offset;
+	memcpy(dst->header, src->header, sizeof(dst->header));
+	memcpy(dst->line, src->line, sizeof(dst->line));
+	dst->rlPart1 = src->rlPart1;
+	dst->rlPart2 = src->rlPart2;
 }
 
 /*! \brief Used for 200 OK and 183 early media 




More information about the asterisk-commits mailing list