... | ... |
@@ -26,8 +26,10 @@ |
26 | 26 |
* |
27 | 27 |
* History: |
28 | 28 |
* --------- |
29 |
- * 2003-02-28 scratchpad compatibility abandoned (jiri) |
|
30 |
- * 2003-01-29 removed scratchpad (jiri) |
|
29 |
+ * 2003-02-28 scratchpad compatibility abandoned (jiri) |
|
30 |
+ * 2003-01-29 removed scratchpad (jiri) |
|
31 |
+ * 2003-03-19 fixed set* len calculation bug & simplified a little the code |
|
32 |
+ * (should be a little faster now) (andrei) |
|
31 | 33 |
*/ |
32 | 34 |
|
33 | 35 |
|
... | ... |
@@ -414,7 +416,8 @@ int do_action(struct action* a, struct sip_msg* msg) |
414 | 416 |
tmp=a->p1.string; |
415 | 417 |
len=strlen(tmp); if(crt+len>end) goto error_uri; |
416 | 418 |
memcpy(crt,tmp,len);crt+=len; |
417 |
- /* whateever we had before, with prefix we have username now */ |
|
419 |
+ /* whatever we had before, with prefix we have username |
|
420 |
+ now */ |
|
418 | 421 |
user=1; |
419 | 422 |
} |
420 | 423 |
|
... | ... |
@@ -423,8 +426,9 @@ int do_action(struct action* a, struct sip_msg* msg) |
423 | 426 |
len=strlen(tmp); |
424 | 427 |
} else if (a->type==STRIP_T) { |
425 | 428 |
if (a->p1.number>uri.user.len) { |
426 |
- LOG(L_WARN, "Error: too long strip asked; deleting username: " |
|
427 |
- "%d of <%.*s>\n", a->p1.number, uri.user.len, uri.user.s ); |
|
429 |
+ LOG(L_WARN, "Error: too long strip asked; " |
|
430 |
+ " deleting username: %d of <%.*s>\n", |
|
431 |
+ a->p1.number, uri.user.len, uri.user.s ); |
|
428 | 432 |
len=0; |
429 | 433 |
} else if (a->p1.number==uri.user.len) { |
430 | 434 |
len=0; |
... | ... |
@@ -447,19 +451,19 @@ int do_action(struct action* a, struct sip_msg* msg) |
447 | 451 |
else tmp=uri.passwd.s; |
448 | 452 |
/* passwd */ |
449 | 453 |
if (tmp){ |
450 |
- len=strlen(":"); if(crt+len>end) goto error_uri; |
|
451 |
- memcpy(crt,":",len);crt+=len; |
|
452 |
- len=uri.passwd.len; if(crt+len>end) goto error_uri; |
|
454 |
+ len=uri.passwd.len; if(crt+len+1>end) goto error_uri; |
|
455 |
+ *crt=':'; crt++; |
|
453 | 456 |
memcpy(crt,tmp,len);crt+=len; |
454 | 457 |
} |
455 | 458 |
/* host */ |
456 | 459 |
if (user || tmp){ /* add @ */ |
457 |
- len=strlen("@"); if(crt+len>end) goto error_uri; |
|
458 |
- memcpy(crt,"@",len);crt+=len; |
|
460 |
+ if(crt+1>end) goto error_uri; |
|
461 |
+ *crt='@'; crt++; |
|
459 | 462 |
} |
460 | 463 |
if ((a->type==SET_HOST_T) ||(a->type==SET_HOSTPORT_T)) { |
461 | 464 |
tmp=a->p1.string; |
462 | 465 |
if (tmp) len = strlen(tmp); |
466 |
+ else len=0; |
|
463 | 467 |
} else { |
464 | 468 |
tmp=uri.host.s; |
465 | 469 |
len = uri.host.len; |
... | ... |
@@ -473,30 +477,28 @@ int do_action(struct action* a, struct sip_msg* msg) |
473 | 477 |
else if (a->type==SET_PORT_T) { |
474 | 478 |
tmp=a->p1.string; |
475 | 479 |
if (tmp) len = strlen(tmp); |
480 |
+ else len = 0; |
|
476 | 481 |
} else { |
477 | 482 |
tmp=uri.port.s; |
478 | 483 |
len = uri.port.len; |
479 | 484 |
} |
480 | 485 |
if (tmp){ |
481 |
- len=strlen(":"); if(crt+len>end) goto error_uri; |
|
482 |
- memcpy(crt,":",len);crt+=len; |
|
483 |
- len=strlen(tmp); if(crt+len>end) goto error_uri; |
|
486 |
+ if(crt+len+1>end) goto error_uri; |
|
487 |
+ *crt=':'; crt++; |
|
484 | 488 |
memcpy(crt,tmp,len);crt+=len; |
485 | 489 |
} |
486 | 490 |
/* params */ |
487 | 491 |
tmp=uri.params.s; |
488 | 492 |
if (tmp){ |
489 |
- len=strlen(";"); if(crt+len>end) goto error_uri; |
|
490 |
- memcpy(crt,";",len);crt+=len; |
|
491 |
- len=uri.params.len; if(crt+len>end) goto error_uri; |
|
493 |
+ len=uri.params.len; if(crt+len+1>end) goto error_uri; |
|
494 |
+ *crt=';'; crt++; |
|
492 | 495 |
memcpy(crt,tmp,len);crt+=len; |
493 | 496 |
} |
494 | 497 |
/* headers */ |
495 | 498 |
tmp=uri.headers.s; |
496 | 499 |
if (tmp){ |
497 |
- len=strlen("?"); if(crt+len>end) goto error_uri; |
|
498 |
- memcpy(crt,"?",len);crt+=len; |
|
499 |
- len=uri.headers.len; if(crt+len>end) goto error_uri; |
|
500 |
+ len=uri.headers.len; if(crt+len+1>end) goto error_uri; |
|
501 |
+ *crt='?'; crt++; |
|
500 | 502 |
memcpy(crt,tmp,len);crt+=len; |
501 | 503 |
} |
502 | 504 |
*crt=0; /* null terminate the thing */ |