... | ... |
@@ -359,7 +359,7 @@ error_len: |
359 | 359 |
*/ |
360 | 360 |
inline static int binrpc_add_skip(struct binrpc_pkt* pkt, int bytes) |
361 | 361 |
{ |
362 |
- |
|
362 |
+ |
|
363 | 363 |
if ((pkt->crt+bytes)>=pkt->end) |
364 | 364 |
return E_BINRPC_OVERFLOW; |
365 | 365 |
pkt->crt+=bytes; |
... | ... |
@@ -373,7 +373,7 @@ inline static int binrpc_add_skip(struct binrpc_pkt* pkt, int bytes) |
373 | 373 |
* manually later (and also use binrpc_add_skip(pkt, l) or increase |
374 | 374 |
* pkt->crt directly if you want to continue adding to this pkt). |
375 | 375 |
* Usefull for optimizing str writing (e.g. writev(iovec)) |
376 |
- * WARNING: use with care, low level function, binrpc_addstr or |
|
376 |
+ * WARNING: use with care, low level function, binrpc_addstr or |
|
377 | 377 |
* binrpc_add_str_type are probably what you want. |
378 | 378 |
* WARNING1: BINRPC_T_STR and BINRPC_T_AVP must be 0 term, the len passed to |
379 | 379 |
* this function, must include the \0 in this case. |
... | ... |
@@ -383,7 +383,7 @@ inline static int binrpc_add_str_mark(struct binrpc_pkt* pkt, int type, |
383 | 383 |
{ |
384 | 384 |
int size; |
385 | 385 |
unsigned char* p; |
386 |
- |
|
386 |
+ |
|
387 | 387 |
if (pkt->crt>=pkt->end) goto error_len; |
388 | 388 |
if (l<8){ |
389 | 389 |
size=l; |
... | ... |
@@ -410,7 +410,7 @@ inline static int binrpc_add_str_type(struct binrpc_pkt* pkt, char* s, int len, |
410 | 410 |
int l; |
411 | 411 |
int zero_term; /* whether or not to add an extra 0 at the end */ |
412 | 412 |
unsigned char* p; |
413 |
- |
|
413 |
+ |
|
414 | 414 |
zero_term=((type==BINRPC_T_STR)||(type==BINRPC_T_AVP)); |
415 | 415 |
l=len+zero_term; |
416 | 416 |
if (l<8){ |
... | ... |
@@ -439,7 +439,7 @@ inline static int binrpc_addavp(struct binrpc_pkt* pkt, struct binrpc_val* avp) |
439 | 439 |
{ |
440 | 440 |
int ret; |
441 | 441 |
unsigned char* bak; |
442 |
- |
|
442 |
+ |
|
443 | 443 |
bak=pkt->crt; |
444 | 444 |
ret=binrpc_add_str_type(pkt, avp->name.s, avp->name.len, BINRPC_T_AVP); |
445 | 445 |
if (ret<0) return ret; |
... | ... |
@@ -449,7 +449,7 @@ inline static int binrpc_addavp(struct binrpc_pkt* pkt, struct binrpc_val* avp) |
449 | 449 |
break; |
450 | 450 |
case BINRPC_T_STR: |
451 | 451 |
case BINRPC_T_BYTES: |
452 |
- ret=binrpc_add_str_type(pkt, avp->u.strval.s, |
|
452 |
+ ret=binrpc_add_str_type(pkt, avp->u.strval.s, |
|
453 | 453 |
avp->u.strval.len, |
454 | 454 |
avp->type); |
455 | 455 |
break; |
... | ... |
@@ -457,7 +457,7 @@ inline static int binrpc_addavp(struct binrpc_pkt* pkt, struct binrpc_val* avp) |
457 | 457 |
case BINRPC_T_ARRAY: |
458 | 458 |
ret=binrpc_add_tag(pkt, avp->type, 0); |
459 | 459 |
break; |
460 |
- case BINRPC_T_DOUBLE: |
|
460 |
+ case BINRPC_T_DOUBLE: |
|
461 | 461 |
ret=binrpc_add_double_type(pkt, avp->u.fval, avp->type); |
462 | 462 |
break; |
463 | 463 |
default: |
... | ... |
@@ -1070,8 +1070,9 @@ static int rpc_struct_add(struct rpc_struct_l* s, char* fmt, ...) |
1070 | 1070 |
case 's': /* asciiz */ |
1071 | 1071 |
avp.type=BINRPC_T_STR; |
1072 | 1072 |
avp.u.strval.s=va_arg(ap, char*); |
1073 |
- if (avp.u.strval.s) |
|
1074 |
- avp.u.strval.len=strlen(avp.u.strval.s); |
|
1073 |
+ if (avp.u.strval.s==0) /* fix null strings */ |
|
1074 |
+ avp.u.strval.s="<null string>"; |
|
1075 |
+ avp.u.strval.len=strlen(avp.u.strval.s); |
|
1075 | 1076 |
break; |
1076 | 1077 |
case 'S': /* str */ |
1077 | 1078 |
avp.type=BINRPC_T_STR; |
... | ... |
@@ -1098,13 +1099,13 @@ static int rpc_struct_add(struct rpc_struct_l* s, char* fmt, ...) |
1098 | 1099 |
} |
1099 | 1100 |
clist_append(&s->substructs, rs, next, prev); |
1100 | 1101 |
*(va_arg(ap, void**))=rs; |
1101 |
- goto end; |
|
1102 |
+ break; |
|
1102 | 1103 |
case 'f': |
1103 | 1104 |
avp.type=BINRPC_T_DOUBLE; |
1104 | 1105 |
avp.u.fval=va_arg(ap, double); |
1105 | 1106 |
break; |
1106 | 1107 |
default: |
1107 |
- LM_ERR("formatting char \'%c\'" " not supported\n", *fmt); |
|
1108 |
+ LM_ERR("formatting char \'%c\' not supported\n", *fmt); |
|
1108 | 1109 |
goto error; |
1109 | 1110 |
} |
1110 | 1111 |
err=binrpc_addavp(&s->pkt, &avp); |