MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / __bencode_decode_string

Function __bencode_decode_string

modules/rtpengine/bencode.c:592–631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590}
591
592static bencode_item_t *__bencode_decode_string(bencode_buffer_t *buf, const char *s, const char *end) {
593 unsigned long int sl;
594 char *convend;
595 const char *orig = s;
596 bencode_item_t *ret;
597
598 if (*s == '0') {
599 sl = 0;
600 s++;
601 goto colon;
602 }
603
604 sl = strtoul(s, &convend, 10);
605 if (convend == s)
606 return NULL;
607 s += (convend - s);
608
609colon:
610 if (s >= end)
611 return NULL;
612 if (*s != ':')
613 return NULL;
614 s++;
615
616 if (s + sl > end)
617 return NULL;
618
619 ret = __bencode_item_alloc(buf, 0);
620 if (!ret)
621 return NULL;
622 ret->type = BENCODE_STRING;
623 ret->iov[0].iov_base = (void *) orig;
624 ret->iov[0].iov_len = s - orig;
625 ret->iov[1].iov_base = (void *) s;
626 ret->iov[1].iov_len = sl;
627 ret->iov_cnt = 2;
628 ret->str_len = s - orig + sl;
629
630 return ret;
631}
632
633static bencode_item_t *__bencode_decode(bencode_buffer_t *buf, const char *s, const char *end) {
634 if (s >= end)

Callers 1

__bencode_decodeFunction · 0.85

Calls 1

__bencode_item_allocFunction · 0.85

Tested by

no test coverage detected