Browse code

core: enclose uri in angle brakets for redirect contact header

- safer for uri with parameters and no q
- reported by Dan Bogos

Daniel-Constantin Mierla authored on 27/05/2013 14:54:02
Showing 1 changed files
... ...
@@ -461,9 +461,11 @@ char* print_dset(struct sip_msg* msg, int* len)
461 461
 
462 462
 	if (msg->new_uri.s) {
463 463
 		cnt = 1;
464
-		*len = msg->new_uri.len;
464
+		*len = msg->new_uri.len + 1 /*'<'*/;
465 465
 		if (ruri_q != Q_UNSPECIFIED) {
466
-			*len += 1 + Q_PARAM_LEN + len_q(ruri_q);
466
+			*len += Q_PARAM_LEN + len_q(ruri_q);
467
+		} else {
468
+			*len += 1 /*'>'*/;
467 469
 		}
468 470
 	} else {
469 471
 		cnt = 0;
... ...
@@ -476,9 +478,11 @@ char* print_dset(struct sip_msg* msg, int* len)
476 478
 	init_branch_iterator();
477 479
 	while ((uri.s = next_branch(&uri.len, &q, 0, 0, 0, 0, 0, 0, 0))) {
478 480
 		cnt++;
479
-		*len += uri.len;
481
+		*len += uri.len + 1 /*'<'*/;
480 482
 		if (q != Q_UNSPECIFIED) {
481
-			*len += 1 + Q_PARAM_LEN + len_q(q);
483
+			*len += Q_PARAM_LEN + len_q(q);
484
+		} else {
485
+			*len += 1 /*'>'*/;
482 486
 		}
483 487
 	}
484 488
 
... ...
@@ -494,9 +498,7 @@ char* print_dset(struct sip_msg* msg, int* len)
494 498
 	memcpy(dset, CONTACT, CONTACT_LEN);
495 499
 	p = dset + CONTACT_LEN;
496 500
 	if (msg->new_uri.s) {
497
-		if (ruri_q != Q_UNSPECIFIED) {
498
-			*p++ = '<';
499
-		}
501
+		*p++ = '<';
500 502
 
501 503
 		memcpy(p, msg->new_uri.s, msg->new_uri.len);
502 504
 		p += msg->new_uri.len;
... ...
@@ -508,6 +510,8 @@ char* print_dset(struct sip_msg* msg, int* len)
508 510
 			qbuf = q2str(ruri_q, &qlen);
509 511
 			memcpy(p, qbuf, qlen);
510 512
 			p += qlen;
513
+		} else {
514
+			*p++ = '>';
511 515
 		}
512 516
 		i = 1;
513 517
 	} else {
... ...
@@ -521,9 +525,7 @@ char* print_dset(struct sip_msg* msg, int* len)
521 525
 			p += CONTACT_DELIM_LEN;
522 526
 		}
523 527
 
524
-		if (q != Q_UNSPECIFIED) {
525
-			*p++ = '<';
526
-		}
528
+		*p++ = '<';
527 529
 
528 530
 		memcpy(p, uri.s, uri.len);
529 531
 		p += uri.len;
... ...
@@ -534,6 +536,8 @@ char* print_dset(struct sip_msg* msg, int* len)
534 536
 			qbuf = q2str(q, &qlen);
535 537
 			memcpy(p, qbuf, qlen);
536 538
 			p += qlen;
539
+		} else {
540
+			*p++ = '>';
537 541
 		}
538 542
 		i++;
539 543
 	}