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 476
 	init_branch_iterator();
477 477
 	while ((uri.s = next_branch(&uri.len, &q, 0, 0, 0, 0, 0, 0, 0))) {
478 478
 		cnt++;
479
-		*len += uri.len;
479
+		*len += uri.len + 1 /*'<'*/;
480 480
 		if (q != Q_UNSPECIFIED) {
481
-			*len += 1 + Q_PARAM_LEN + len_q(q);
481
+			*len += Q_PARAM_LEN + len_q(q);
482
+		} else {
483
+			*len += 1 /*'>'*/;
482 484
 		}
483 485
 	}
484 486
 
... ...
@@ -494,9 +498,7 @@ char* print_dset(struct sip_msg* msg, int* len)
494 494
 	memcpy(dset, CONTACT, CONTACT_LEN);
495 495
 	p = dset + CONTACT_LEN;
496 496
 	if (msg->new_uri.s) {
497
-		if (ruri_q != Q_UNSPECIFIED) {
498
-			*p++ = '<';
499
-		}
497
+		*p++ = '<';
500 498
 
501 499
 		memcpy(p, msg->new_uri.s, msg->new_uri.len);
502 500
 		p += msg->new_uri.len;
... ...
@@ -508,6 +510,8 @@ char* print_dset(struct sip_msg* msg, int* len)
508 508
 			qbuf = q2str(ruri_q, &qlen);
509 509
 			memcpy(p, qbuf, qlen);
510 510
 			p += qlen;
511
+		} else {
512
+			*p++ = '>';
511 513
 		}
512 514
 		i = 1;
513 515
 	} else {
... ...
@@ -521,9 +525,7 @@ char* print_dset(struct sip_msg* msg, int* len)
521 521
 			p += CONTACT_DELIM_LEN;
522 522
 		}
523 523
 
524
-		if (q != Q_UNSPECIFIED) {
525
-			*p++ = '<';
526
-		}
524
+		*p++ = '<';
527 525
 
528 526
 		memcpy(p, uri.s, uri.len);
529 527
 		p += uri.len;
... ...
@@ -534,6 +536,8 @@ char* print_dset(struct sip_msg* msg, int* len)
534 534
 			qbuf = q2str(q, &qlen);
535 535
 			memcpy(p, qbuf, qlen);
536 536
 			p += qlen;
537
+		} else {
538
+			*p++ = '>';
537 539
 		}
538 540
 		i++;
539 541
 	}