summaryrefslogtreecommitdiff
path: root/pjnath/src/pjnath/stun_msg.c
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-01-02 08:24:10 +0000
committerBenny Prijono <bennylp@teluu.com>2008-01-02 08:24:10 +0000
commit7224fb899a0bdfb47773329a227f4bca452b2748 (patch)
tree7b2294bbda29f426f9b6a5cca5538da7a4443d35 /pjnath/src/pjnath/stun_msg.c
parentf823177cae22a9be300a01ecdaa791f3cc2b19ac (diff)
Ticket #437: reduce stack and pool usage on pjnath to make it work better on Symbian
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1654 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath/src/pjnath/stun_msg.c')
-rw-r--r--pjnath/src/pjnath/stun_msg.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/pjnath/src/pjnath/stun_msg.c b/pjnath/src/pjnath/stun_msg.c
index 125b3bda..9590fee6 100644
--- a/pjnath/src/pjnath/stun_msg.c
+++ b/pjnath/src/pjnath/stun_msg.c
@@ -707,6 +707,8 @@ static pj_status_t decode_sockaddr_attr(pj_pool_t *pool,
pj_stun_sockaddr_attr *attr;
pj_uint32_t val;
+ PJ_CHECK_STACK();
+
/* Create the attribute */
attr = PJ_POOL_ZALLOC_T(pool, pj_stun_sockaddr_attr);
GETATTRHDR(buf, &attr->hdr);
@@ -771,6 +773,8 @@ static pj_status_t encode_sockaddr_attr(const void *a, pj_uint8_t *buf,
if (len < ATTR_LEN)
return PJ_ETOOSMALL;
+ PJ_CHECK_STACK();
+
/* Copy and convert headers to network byte order */
PUTVAL16H(buf, 0, ca->hdr.type);
PUTVAL16H(buf, 2, STUN_GENERIC_IP_ADDR_LEN);
@@ -899,6 +903,8 @@ static pj_status_t encode_string_attr(const void *a, pj_uint8_t *buf,
const pj_stun_string_attr *ca =
(const pj_stun_string_attr*)a;
+ PJ_CHECK_STACK();
+
/* Calculated total attr_len (add padding if necessary) */
*printed = (ca->value.slen + ATTR_HDR_LEN + 3) & (~3);
if (len < *printed) {
@@ -1080,6 +1086,8 @@ static pj_status_t encode_uint_attr(const void *a, pj_uint8_t *buf,
{
const pj_stun_uint_attr *ca = (const pj_stun_uint_attr*)a;
+ PJ_CHECK_STACK();
+
if (len < 8)
return PJ_ETOOSMALL;
@@ -1163,6 +1171,8 @@ static pj_status_t encode_uint64_attr(const void *a, pj_uint8_t *buf,
{
const pj_stun_uint64_attr *ca = (const pj_stun_uint64_attr*)a;
+ PJ_CHECK_STACK();
+
if (len < 12)
return PJ_ETOOSMALL;
@@ -1242,6 +1252,8 @@ static pj_status_t encode_msgint_attr(const void *a, pj_uint8_t *buf,
{
const pj_stun_msgint_attr *ca = (const pj_stun_msgint_attr*)a;
+ PJ_CHECK_STACK();
+
if (len < 24)
return PJ_ETOOSMALL;
@@ -1346,6 +1358,8 @@ static pj_status_t encode_errcode_attr(const void *a, pj_uint8_t *buf,
const pj_stun_errcode_attr *ca =
(const pj_stun_errcode_attr*)a;
+ PJ_CHECK_STACK();
+
if (len < ATTR_HDR_LEN + 4 + (unsigned)ca->reason.slen)
return PJ_ETOOSMALL;
@@ -1461,6 +1475,8 @@ static pj_status_t encode_unknown_attr(const void *a, pj_uint8_t *buf,
pj_uint16_t *dst_unk_attr;
unsigned i;
+ PJ_CHECK_STACK();
+
/* Check that buffer is enough */
if (len < ATTR_HDR_LEN + (ca->attr_count << 1))
return PJ_ETOOSMALL;
@@ -1561,6 +1577,8 @@ static pj_status_t encode_binary_attr(const void *a, pj_uint8_t *buf,
{
const pj_stun_binary_attr *ca = (const pj_stun_binary_attr*)a;
+ PJ_CHECK_STACK();
+
/* Calculated total attr_len (add padding if necessary) */
*printed = (ca->length + ATTR_HDR_LEN + 3) & (~3);
if (len < *printed)